Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1210)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8StringResource.cpp

Issue 1389383003: WIP: Introduce CompressibleString Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto crrev.com/1564773002 Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/V8StringResource.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8StringResource.cpp b/third_party/WebKit/Source/bindings/core/v8/V8StringResource.cpp
index a3d51c99a7cffe26b14c255ae334807e9d4aaa9f..70149e9ac82963a895f3c9470e9f2892542fac4d 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8StringResource.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8StringResource.cpp
@@ -38,7 +38,7 @@ template<class StringClass> struct StringTraits {
template<>
struct StringTraits<String> {
- static const String& fromStringResource(WebCoreStringResourceBase* resource)
+ static String fromStringResource(WebCoreStringResourceBase* resource)
{
return resource->webcoreString();
}
@@ -48,7 +48,7 @@ struct StringTraits<String> {
template<>
struct StringTraits<AtomicString> {
- static const AtomicString& fromStringResource(WebCoreStringResourceBase* resource)
+ static AtomicString fromStringResource(WebCoreStringResourceBase* resource)
{
return resource->atomicString();
}
@@ -107,10 +107,17 @@ StringType v8StringToWebCoreString(v8::Local<v8::String> v8String, ExternalMode
v8::String::ExternalStringResourceBase* resource = v8String->GetExternalStringResourceBase(&encoding);
if (LIKELY(!!resource)) {
WebCoreStringResourceBase* base;
- if (encoding == v8::String::ONE_BYTE_ENCODING)
- base = static_cast<WebCoreStringResource8*>(resource);
- else
- base = static_cast<WebCoreStringResource16*>(resource);
+ if (UNLIKELY(resource->IsCompressible())) {
+ if (encoding == v8::String::ONE_BYTE_ENCODING)
+ base = static_cast<WebCoreCompressibleStringResource8*>(resource);
+ else
+ base = static_cast<WebCoreCompressibleStringResource16*>(resource);
+ } else {
+ if (encoding == v8::String::ONE_BYTE_ENCODING)
+ base = static_cast<WebCoreStringResource8*>(resource);
+ else
+ base = static_cast<WebCoreStringResource16*>(resource);
+ }
return StringTraits<StringType>::fromStringResource(base);
}
}

Powered by Google App Engine
This is Rietveld 408576698