1 /* Copyright (C) 1998, 1999 Aladdin Enterprises. All rights reserved. 2 3 This software is provided AS-IS with no warranty, either express or 4 implied. 5 6 This software is distributed under license and may not be copied, 7 modified or distributed except as expressly authorized under the terms 8 of the license contained in the file LICENSE in this distribution. 9 10 For more information about licensing, please refer to 11 http://www.ghostscript.com/licensing/. For information on 12 commercial licensing, go to http://www.artifex.com/licensing/ or 13 contact Artifex Software, Inc., 101 Lucas Valley Road #110, 14 San Rafael, CA 94903, U.S.A., +1(415)492-9861. 15 */ 16 17 /* $Id: idstack.h,v 1.5 2002/06/16 04:47:10 lpd Exp $ */ 18 /* Generic dictionary stack API */ 19 20 #ifndef idstack_INCLUDED 21 # define idstack_INCLUDED 22 23 #include "iddstack.h" 24 #include "idsdata.h" 25 #include "istack.h" 26 27 /* Define the type of pointers into the dictionary stack. */ 28 typedef s_ptr ds_ptr; 29 typedef const_s_ptr const_ds_ptr; 30 31 /* Clean up a dictionary stack after a garbage collection. */ 32 void dstack_gc_cleanup(dict_stack_t *); 33 34 /* 35 * Define a special fast entry for name lookup on a dictionary stack. 36 * The key is known to be a name; search the entire dict stack. 37 * Return the pointer to the value slot. 38 * If the name isn't found, just return 0. 39 */ 40 ref *dstack_find_name_by_index(dict_stack_t *, uint); 41 42 /* 43 * Define an extra-fast macro for name lookup, optimized for 44 * a single-probe lookup in the top dictionary on the stack. 45 * Amazingly enough, this seems to hit over 90% of the time 46 * (aside from operators, of course, which are handled either with 47 * the special cache pointer or with 'bind'). 48 */ 49 #define dstack_find_name_by_index_inline(pds,nidx,htemp)\ 50 ((pds)->top_keys[htemp = dict_hash_mod_inline(dict_name_index_hash(nidx),\ 51 (pds)->top_npairs) + 1] == pt_tag(pt_literal_name) + (nidx) ?\ 52 (pds)->top_values + htemp : dstack_find_name_by_index(pds, nidx)) 53 /* 54 * Define a similar macro that only checks the top dictionary on the stack. 55 */ 56 #define if_dstack_find_name_by_index_top(pds,nidx,htemp,pvslot)\ 57 if ( (((pds)->top_keys[htemp = dict_hash_mod_inline(dict_name_index_hash(nidx),\ 58 (pds)->top_npairs) + 1] == pt_tag(pt_literal_name) + (nidx)) ?\ 59 ((pvslot) = (pds)->top_values + (htemp), 1) :\ 60 0)\ 61 ) 62 63 #endif /* idstack_INCLUDED */ 64