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

Unified Diff: Source/core/css/CSSPrimitiveValue.h

Issue 1268683002: CSSValue Immediates: Micro-optimize reinterpret_casts for immediates (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@tagged_ptrs_base
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSPrimitiveValue.h
diff --git a/Source/core/css/CSSPrimitiveValue.h b/Source/core/css/CSSPrimitiveValue.h
index 1820b226d24c511e3c90c80db830cb3cfecda590..24752549d51358151dd802f0415d3825b4af6b52 100644
--- a/Source/core/css/CSSPrimitiveValue.h
+++ b/Source/core/css/CSSPrimitiveValue.h
@@ -445,17 +445,14 @@ private:
return reinterpret_cast<CSSPrimitiveValue*&>(taggedPtr);
}
- inline CSSTaggedPtrValue toTaggedPtr() const
- {
- CSSPrimitiveValue* nonConstThis = const_cast<CSSPrimitiveValue*>(this);
- return reinterpret_cast<CSSTaggedPtrValue&&>(nonConstThis);
- }
-
inline UnitType type() const
{
if (!isTaggedPtr())
return static_cast<UnitType>(m_primitiveUnitType);
- return static_cast<UnitType>(toTaggedPtr().type);
+
+ const CSSPrimitiveValue* const& lValue = this;
+ const CSSTaggedPtrValue& taggedPtr = reinterpret_cast<const CSSTaggedPtrValue&>(lValue);
+ return static_cast<UnitType>(taggedPtr.type);
}
inline CSSPrimitiveValueData value() const
@@ -464,16 +461,18 @@ private:
return m_value;
CSSPrimitiveValueData data;
+ const CSSPrimitiveValue* const& lValue = this;
+ const CSSTaggedPtrValue& taggedPtr = reinterpret_cast<const CSSTaggedPtrValue&>(lValue);
switch (type()) {
case CSSPrimitiveValue::CSS_PROPERTY_ID:
- data.propertyID = static_cast<CSSPropertyID>(toTaggedPtr().value);
+ data.propertyID = static_cast<CSSPropertyID>(taggedPtr.value);
break;
case CSSPrimitiveValue::CSS_VALUE_ID:
- data.valueID = static_cast<CSSValueID>(toTaggedPtr().value);
+ data.valueID = static_cast<CSSValueID>(taggedPtr.value);
break;
case CSSPrimitiveValue::CSS_RGBCOLOR: {
- uintptr_t valueRawVar = toTaggedPtr().value;
- packedColor color = *reinterpret_cast<packedColor*>(&valueRawVar);
+ uintptr_t colorRaw = taggedPtr.value;
+ packedColor color = reinterpret_cast<packedColor&>(colorRaw);
unsigned alpha;
#if CPU(32BIT)
alpha = color.alpha == 1 ? 255 : 0;
@@ -484,9 +483,9 @@ private:
break;
}
default:
- uint64_t shiftedValue = toTaggedPtr().value;
+ uint64_t shiftedValue = taggedPtr.value;
shiftedValue = shiftedValue << doubleShiftAmount;
- data.num = *reinterpret_cast<double*>(&shiftedValue);
+ data.num = reinterpret_cast<double&>(shiftedValue);
break;
}
return data;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698