v8::Handle<v8::String> StringCache::v8ExternalStringSlow(StringImpl* stringImpl, v8::Isolate* isolate) { if (!stringImpl->length()) return v8::String::Empty(isolate); UnsafePersistent<v8::String> cachedV8String = m_stringCache.get(stringImpl); if (!cachedV8String.isEmpty()) { m_lastStringImpl = stringImpl; m_lastV8String = cachedV8String; return cachedV8String.newLocal(isolate); } return createStringAndInsertIntoCache(stringImpl, isolate); }
v8::Handle<v8::String> StringCache::v8ExternalStringSlow(v8::Isolate* isolate, StringImpl* stringImpl) { if (!stringImpl->length()) return v8::String::Empty(isolate); StringCacheMapTraits::MapType::PersistentValueReference cachedV8String = m_stringCache.GetReference(stringImpl); if (!cachedV8String.IsEmpty()) { m_lastStringImpl = stringImpl; m_lastV8String = cachedV8String; return m_lastV8String.NewLocal(isolate); } return createStringAndInsertIntoCache(isolate, stringImpl); }
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)); }