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

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

Issue 1583263002: Experimental CompressibleString UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adopt lazy-initializing way 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..0fed16ac2f70c1bcf3e7d2cad71108ac6a4b23e6 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8StringResource.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8StringResource.cpp
@@ -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