Add a hash function for families

Add a hash function that behaves like family
comparison: ignoring case and blanks. This
will be used to replace the list walking for
finding family matches with a hash table.
This commit is contained in:
Matthias Clasen 2020-08-21 08:05:18 -04:00
parent 46d818df26
commit 055843631b
2 changed files with 16 additions and 0 deletions

View File

@ -1328,6 +1328,9 @@ FcStrLastSlash (const FcChar8 *path);
FcPrivate FcChar32
FcStrHashIgnoreCase (const FcChar8 *s);
FcPrivate FcChar32
FcStrHashIgnoreBlanksAndCase (const FcChar8 *s);
FcPrivate FcChar8 *
FcStrCanonFilename (const FcChar8 *s);

View File

@ -320,6 +320,19 @@ FcStrHashIgnoreCase (const FcChar8 *s)
return h;
}
FcChar32
FcStrHashIgnoreBlanksAndCase (const FcChar8 *s)
{
FcChar32 h = 0;
FcCaseWalker w;
FcChar8 c;
FcStrCaseWalkerInit (s, &w);
while ((c = FcStrCaseWalkerNextNonBlank (&w)))
h = ((h << 3) ^ (h >> 3)) ^ c;
return h;
}
/*
* Is the head of s1 equal to s2?
*/