本文整理汇总了C++中mozilla::HashString方法的典型用法代码示例。如果您正苦于以下问题:C++ mozilla::HashString方法的具体用法?C++ mozilla::HashString怎么用?C++ mozilla::HashString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozilla
的用法示例。
在下文中一共展示了mozilla::HashString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddToHash
/* static */ HashNumber
EvalCacheHashPolicy::hash(const EvalCacheLookup &l)
{
AutoCheckCannotGC nogc;
uint32_t hash = l.str->hasLatin1Chars()
? HashString(l.str->latin1Chars(nogc), l.str->length())
: HashString(l.str->twoByteChars(nogc), l.str->length());
return AddToHash(hash, l.callerScript.get(), l.version, l.pc);
}
示例2: AddToHash
/* static */ HashNumber
EvalCacheHashPolicy::hash(const EvalCacheLookup &l)
{
return AddToHash(HashString(l.str->chars(), l.str->length()),
l.callerScript.get(),
l.version,
l.pc);
}
示例3: AddToHash
/* static */ HashNumber
EvalCacheHashPolicy::hash(const EvalCacheLookup &l)
{
return AddToHash(HashString(l.str->chars(), l.str->length()),
l.caller,
l.staticLevel,
l.version,
l.compartment);
}
示例4: HashString
bool
FindHashMatch(const Metadata& aMetadata, const ReadParams& aReadParams,
uint32_t* aModuleIndex)
{
// Perform a fast hash of the first sNumFastHashChars chars. Each cache entry
// also stores an mFastHash of its first sNumFastHashChars so this gives us a
// fast way to probabilistically determine whether we have a cache hit. We
// still do a full hash of all the chars before returning the cache file to
// the engine to avoid penalizing the case where there are multiple cached
// asm.js modules where the first sNumFastHashChars are the same. The
// mFullHash of each cache entry can have a different mNumChars so the fast
// hash allows us to avoid performing up to Metadata::kNumEntries separate
// full hashes.
uint32_t numChars = aReadParams.mLimit - aReadParams.mBegin;
MOZ_ASSERT(numChars > sNumFastHashChars);
uint32_t fastHash = HashString(aReadParams.mBegin, sNumFastHashChars);
for (unsigned i = 0; i < Metadata::kNumEntries ; i++) {
// Compare the "fast hash" first to see whether it is worthwhile to
// hash all the chars.
Metadata::Entry entry = aMetadata.mEntries[i];
if (entry.mFastHash != fastHash) {
continue;
}
// Assuming we have enough characters, hash all the chars it would take
// to match this cache entry and compare to the cache entry. If we get a
// hit we'll still do a full source match later (in the JS engine), but
// the full hash match means this is probably the cache entry we want.
if (numChars < entry.mNumChars) {
continue;
}
uint32_t fullHash = HashString(aReadParams.mBegin, entry.mNumChars);
if (entry.mFullHash != fullHash) {
continue;
}
*aModuleIndex = entry.mModuleIndex;
return true;
}
return false;
}