summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1236419)
This one has some obvious collisions for non-alphabetical characters,
like some control characters also hashing to numbers, but we don't
really have those, and these are hash functions which are not
collision free to begin with.
#define tolower_ascii tolower_ascii_inline
#define isspace_ascii isspace_ascii_inline
#define tolower_ascii tolower_ascii_inline
#define isspace_ascii isspace_ascii_inline
+APT_CONST APT_HOT
+static inline int tolower_ascii_unsafe(int const c)
+{
+ return c | 0x20;
+}
APT_CONST APT_HOT
static inline int tolower_ascii_inline(int const c)
{
APT_CONST APT_HOT
static inline int tolower_ascii_inline(int const c)
{
{
if (isspace_ascii(*Start) != 0)
continue;
{
if (isspace_ascii(*Start) != 0)
continue;
- *J++ = tolower_ascii(*Start);
+ *J++ = tolower_ascii_unsafe(*Start);
/* Normalize <= to < and >= to >. This is the wrong way around, but
* more efficient that the right way. And since we're only hashing
/* Normalize <= to < and >= to >. This is the wrong way around, but
* more efficient that the right way. And since we're only hashing
{
uint32_t Hash = 5381;
for (auto I = Str.begin(); I != Str.end(); ++I)
{
uint32_t Hash = 5381;
for (auto I = Str.begin(); I != Str.end(); ++I)
- Hash = 33 * Hash + tolower_ascii(*I);
+ Hash = 33 * Hash + tolower_ascii_unsafe(*I);
return Hash % HeaderP->GetHashTableSize();
}
map_id_t pkgCache::sHash(const string &Str) const
{
uint32_t Hash = 5381;
for (string::const_iterator I = Str.begin(); I != Str.end(); ++I)
return Hash % HeaderP->GetHashTableSize();
}
map_id_t pkgCache::sHash(const string &Str) const
{
uint32_t Hash = 5381;
for (string::const_iterator I = Str.begin(); I != Str.end(); ++I)
- Hash = 33 * Hash + tolower_ascii((signed char)*I);
+ Hash = 33 * Hash + tolower_ascii_unsafe((signed char)*I);
return Hash % HeaderP->GetHashTableSize();
}
return Hash % HeaderP->GetHashTableSize();
}
{
uint32_t Hash = 5381;
for (const char *I = Str; *I != 0; ++I)
{
uint32_t Hash = 5381;
for (const char *I = Str; *I != 0; ++I)
- Hash = 33 * Hash + tolower_ascii((signed char)*I);
+ Hash = 33 * Hash + tolower_ascii_unsafe((signed char)*I);
return Hash % HeaderP->GetHashTableSize();
}
return Hash % HeaderP->GetHashTableSize();
}