Changeset 287 for trunk/src/gmake/hash.h


Ignore:
Timestamp:
May 17, 2005, 1:34:55 AM (20 years ago)
Author:
bird
Message:

join + optimizations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmake/hash.h

    r53 r287  
    8383/* hash and comparison macros for case-sensitive string keys. */
    8484
     85#if 0
    8586#define STRING_HASH_1(KEY, RESULT) do { \
    8687  unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
     
    8889    (RESULT) += (*_key_ << (_key_[1] & 0xf)); \
    8990} while (0)
     91#else
     92#define STRING_HASH_1(KEY, RESULT) do { \
     93  unsigned char const *_key_ = (unsigned char const *) (KEY); \
     94  unsigned int _ch_ = *_key_; \
     95  while (_ch_) \
     96    { \
     97      unsigned char _ch2_ = *++_key_; \
     98     (RESULT) += (_ch_ << (_ch2_ & 0xf)); \
     99     _ch_ = _ch2_; \
     100    } \
     101} while (0)
     102#endif
    90103#define return_STRING_HASH_1(KEY) do { \
    91104  unsigned long _result_ = 0; \
     
    94107} while (0)
    95108
     109#if 0
    96110#define STRING_HASH_2(KEY, RESULT) do { \
    97111  unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
     
    99113    (RESULT) += (*_key_ << (_key_[1] & 0x7)); \
    100114} while (0)
     115#else
     116#define STRING_HASH_2(KEY, RESULT) do { \
     117  unsigned char const *_key_ = (unsigned char const *) (KEY); \
     118  unsigned int _ch_ = *_key_; \
     119  while (_ch_) \
     120    { \
     121      unsigned char _ch2_ = *++_key_; \
     122     (RESULT) += (_ch_ << (_ch2_ & 0x7)); \
     123     _ch_ = _ch2_; \
     124    } \
     125} while (0)
     126#endif
    101127#define return_STRING_HASH_2(KEY) do { \
    102128  unsigned long _result_ = 0; \
     
    112138} while (0)
    113139
    114 
    115 #define STRING_N_HASH_1(KEY, N, RESULT) do { \
     140#if 0
     141#define _STRING_N_HASH_1(KEY, N, RESULT) do { \
    116142  unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
    117143  int _n_ = (N); \
     
    121147  (RESULT) += *++_key_; \
    122148} while (0)
     149#else
     150#define STRING_N_HASH_1(KEY, N, RESULT) do { \
     151  unsigned char const *_key_ = (unsigned char const *) (KEY); \
     152  unsigned int _ch_ = *_key_; \
     153  int _n_ = (N); \
     154  if (_n_) \
     155    { \
     156      for (;;) \
     157        { \
     158          unsigned char _ch2_; \
     159          if (!--_n_) \
     160            { \
     161              (RESULT) += _ch_; \
     162              break; \
     163            } \
     164          _ch2_ = *++_key_; \
     165          (RESULT) += (_ch_ << (_ch2_ & 0xf)); \
     166          _ch_ = _ch2_; \
     167          if (!_ch_) break; \
     168        } \
     169    } \
     170  else \
     171    (RESULT) += _ch_; \
     172} while (0)
     173#endif
    123174#define return_STRING_N_HASH_1(KEY, N) do { \
    124175  unsigned long _result_ = 0; \
     
    127178} while (0)
    128179
     180#if 0
    129181#define STRING_N_HASH_2(KEY, N, RESULT) do { \
    130182  unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
     
    135187  (RESULT) += *++_key_; \
    136188} while (0)
     189#else
     190#define STRING_N_HASH_2(KEY, N, RESULT) do { \
     191  unsigned char const *_key_ = (unsigned char const *) (KEY); \
     192  unsigned int _ch_ = *_key_; \
     193  int _n_ = (N); \
     194  if (_n_) \
     195    { \
     196      for (;;) \
     197        { \
     198          unsigned char _ch2_; \
     199          if (!--_n_) \
     200            { \
     201              (RESULT) += _ch_; \
     202              break; \
     203            } \
     204          _ch2_ = *++_key_; \
     205          (RESULT) += (_ch_ << (_ch2_ & 0x7)); \
     206          _ch_ = _ch2_; \
     207          if (!_ch_) break; \
     208        } \
     209    } \
     210  else \
     211    (RESULT) += _ch_; \
     212} while (0)
     213#endif
    137214#define return_STRING_N_HASH_2(KEY, N) do { \
    138215  unsigned long _result_ = 0; \
     
    152229/* hash and comparison macros for case-insensitive string _key_s. */
    153230
     231#if 1 /* testme */
    154232#define ISTRING_HASH_1(KEY, RESULT) do { \
    155233  unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
     
    157235    (RESULT) += ((isupper (*_key_) ? tolower (*_key_) : *_key_) << (_key_[1] & 0xf)); \
    158236} while (0)
     237#else
     238#define ISTRING_HASH_1(KEY, RESULT) do { \
     239  unsigned char const *_key_ = (unsigned char const *) (KEY); \
     240  unsigned int _ch_ = *_key_;
     241  while (_ch_) \
     242    { \
     243      unsigned _ch2_ = *++_key_; \
     244      (RESULT) += ((isupper (_ch_) ? tolower (_ch_) : _ch_) << (_ch2_ & 0xf)); \
     245      _ch_ = _ch2_; \
     246    } \
     247} while (0)
     248#endif
    159249#define return_ISTRING_HASH_1(KEY) do { \
    160250  unsigned long _result_ = 0; \
     
    163253} while (0)
    164254
     255#if 1 /* testme */
    165256#define ISTRING_HASH_2(KEY, RESULT) do { \
    166257  unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \
     
    168259    (RESULT) += ((isupper (*_key_) ? tolower (*_key_) : *_key_) << (_key_[1] & 0x7)); \
    169260} while (0)
     261#else
     262#define ISTRING_HASH_2(KEY, RESULT) do { \
     263  unsigned char const *_key_ = (unsigned char const *) (KEY); \
     264  unsigned int _ch_ = *_key_;
     265  while (_ch_) \
     266    { \
     267      unsigned _ch2_ = *++_key_; \
     268      (RESULT) += ((isupper (_ch_) ? tolower (_ch_) : _ch_) << (_ch2_ & 0x7)); \
     269      _ch_ = _ch2_; \
     270    } \
     271} while (0)
     272#endif
    170273#define return_ISTRING_HASH_2(KEY) do { \
    171274  unsigned long _result_ = 0; \
Note: See TracChangeset for help on using the changeset viewer.