mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-16 07:14:09 +02:00
Linux compilation fix, string hash fix (dramatic speed increase)
This commit is contained in:
parent
634dd7e509
commit
71745110a5
2 changed files with 15 additions and 15 deletions
|
@ -29,7 +29,7 @@ AutoCompleteBase::~AutoCompleteBase()
|
|||
Clear();
|
||||
}
|
||||
|
||||
inline void UpdateEntryMatchindices(uint8* matches, AutoCompleteEntry& entry)
|
||||
inline void UpdateEntryMatchIndices(uint8* matches, const AutoCompleteEntry& entry)
|
||||
{
|
||||
if (matches[0] != UINT8_MAX)
|
||||
{
|
||||
|
@ -55,14 +55,14 @@ inline void UpdateEntryMatchindices(uint8* matches, AutoCompleteEntry& entry)
|
|||
}
|
||||
}
|
||||
|
||||
AutoCompleteEntry* AutoCompleteBase::AddEntry(AutoCompleteEntry& entry, const StringImpl& filter)
|
||||
AutoCompleteEntry* AutoCompleteBase::AddEntry(const AutoCompleteEntry& entry, const StringImpl& filter)
|
||||
{
|
||||
uint8 matches[256];
|
||||
|
||||
if (!DoesFilterMatch(entry.mDisplay, filter.c_str(), entry.mScore, matches, 256) || (entry.mNamePrefixCount < 0))
|
||||
return NULL;
|
||||
|
||||
UpdateEntryMatchindices(matches, entry);
|
||||
UpdateEntryMatchIndices(matches, entry);
|
||||
|
||||
auto result = AddEntry(entry);
|
||||
|
||||
|
@ -73,14 +73,14 @@ AutoCompleteEntry* AutoCompleteBase::AddEntry(AutoCompleteEntry& entry, const St
|
|||
return result;
|
||||
}
|
||||
|
||||
AutoCompleteEntry* AutoCompleteBase::AddEntry(AutoCompleteEntry& entry, const char* filter)
|
||||
AutoCompleteEntry* AutoCompleteBase::AddEntry(const AutoCompleteEntry& entry, const char* filter)
|
||||
{
|
||||
uint8 matches[256];
|
||||
|
||||
if (!DoesFilterMatch(entry.mDisplay, filter, entry.mScore, matches, 256) || (entry.mNamePrefixCount < 0))
|
||||
return NULL;
|
||||
|
||||
UpdateEntryMatchindices(matches, entry);
|
||||
UpdateEntryMatchIndices(matches, entry);
|
||||
|
||||
auto result = AddEntry(entry);
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@ public:
|
|||
const char* mEntryType;
|
||||
const char* mDisplay;
|
||||
const char* mDocumentation;
|
||||
int8 mNamePrefixCount;
|
||||
int mScore;
|
||||
uint8* mMatches;
|
||||
uint8 mMatchesLength;
|
||||
mutable int8 mNamePrefixCount;
|
||||
mutable int mScore;
|
||||
mutable uint8* mMatches;
|
||||
mutable uint8 mMatchesLength;
|
||||
|
||||
public:
|
||||
AutoCompleteEntry()
|
||||
|
@ -81,10 +81,10 @@ struct BeefHash<Beefy::AutoCompleteEntry>
|
|||
char c = *(curPtr++);
|
||||
if (c == 0)
|
||||
break;
|
||||
hash = (hash ^ (intptr)c) - hash;
|
||||
hash = ((hash ^ (intptr)c) << 5) - hash;
|
||||
}
|
||||
|
||||
return (size_t)hash;
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -116,8 +116,8 @@ public:
|
|||
int mInsertEndIdx;
|
||||
|
||||
bool DoesFilterMatch(const char* entry, const char* filter, int& score, uint8* matches, int maxMatches);
|
||||
AutoCompleteEntry* AddEntry(AutoCompleteEntry& entry, const StringImpl& filter);
|
||||
AutoCompleteEntry* AddEntry(AutoCompleteEntry& entry, const char* filter);
|
||||
AutoCompleteEntry* AddEntry(const AutoCompleteEntry& entry, const StringImpl& filter);
|
||||
AutoCompleteEntry* AddEntry(const AutoCompleteEntry& entry, const char* filter);
|
||||
AutoCompleteEntry* AddEntry(const AutoCompleteEntry& entry);
|
||||
|
||||
AutoCompleteBase();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue