Beispiel #1
0
void StringCache::setReturnValueFromStringSlow(v8::ReturnValue<v8::Value> returnValue, StringImpl* stringImpl)
{
    if (!stringImpl->length()) {
        returnValue.SetEmptyString();
        return;
    }

    UnsafePersistent<v8::String> cachedV8String = m_stringCache.get(stringImpl);
    if (!cachedV8String.isEmpty()) {
        m_lastStringImpl = stringImpl;
        m_lastV8String = cachedV8String;
        returnValue.Set(*cachedV8String.persistent());
        return;
    }

    returnValue.Set(createStringAndInsertIntoCache(stringImpl, returnValue.GetIsolate()));
}
void StringCache::setReturnValueFromStringSlow(v8::ReturnValue<v8::Value> returnValue, StringImpl* stringImpl)
{
    if (!stringImpl->length()) {
        returnValue.SetEmptyString();
        return;
    }

    StringCacheMapTraits::MapType::PersistentValueReference cachedV8String = m_stringCache.GetReference(stringImpl);
    if (!cachedV8String.IsEmpty()) {
        m_lastStringImpl = stringImpl;
        m_lastV8String = cachedV8String;
        m_lastV8String.SetReturnValue(returnValue);
        return;
    }

    returnValue.Set(createStringAndInsertIntoCache(returnValue.GetIsolate(), stringImpl));
}