Changeset 1897 for trunk/src/kmk/strcache2.h
- Timestamp:
- Oct 21, 2008, 3:21:39 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/strcache2.h
r1887 r1897 28 28 #define ___strcache2_h 29 29 30 #ifndef CHAR_BIT 31 # error "include after make.h!" 32 #endif 33 30 34 /* string cache memory segment. */ 31 35 struct strcache2_seg … … 46 50 unsigned int length; 47 51 }; 52 53 /* The entry alignment. 54 As it is very difficult to derive this from any #define or typedef, a 55 default value of 16 (chars) was choosen as this fits most platforms. 56 For odd platforms, just override this define. */ 57 #ifndef STRCACHE2_ENTRY_ALIGN_SHIFT 58 # define STRCACHE2_ENTRY_ALIGN_SHIFT 4 59 #endif 60 #define STRCACHE2_ENTRY_ALIGNMENT (1 << STRCACHE2_ENTRY_ALIGN_SHIFT) 61 48 62 49 63 struct strcache2 … … 123 137 } 124 138 139 /* Get the pointer hash value for the string. 140 141 This takes the string address, shift out the bits that are always zero 142 due to alignment, and then returns the unsigned integer value of it. 143 144 The results from using this is generally better than for any of the 145 other hash values. It is also sligtly faster code as it does not 146 involve any memory accesses, just a right SHIFT and an optional AND. */ 147 MY_INLINE unsigned int 148 strcache2_get_ptr_hash (struct strcache2 *cache, const char *str) 149 { 150 (void)cache; 151 return (size_t)str >> STRCACHE2_ENTRY_ALIGN_SHIFT; 152 } 153 125 154 /* Get the user value for the string. */ 126 155 MY_INLINE void *
Note:
See TracChangeset
for help on using the changeset viewer.