summaryrefslogtreecommitdiffstats
path: root/webkit/port/platform
diff options
context:
space:
mode:
authorevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-14 00:17:30 +0000
committerevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-14 00:17:30 +0000
commita95b6ebeb94363671433029e97a488bccb17ff17 (patch)
tree62e666860379503bc56397de84ed66a9b587301d /webkit/port/platform
parent8881d8794f13bf12d8ed7ce93fd163b9992aeb28 (diff)
downloadchromium_src-a95b6ebeb94363671433029e97a488bccb17ff17.zip
chromium_src-a95b6ebeb94363671433029e97a488bccb17ff17.tar.gz
chromium_src-a95b6ebeb94363671433029e97a488bccb17ff17.tar.bz2
Use a memcpy because we don't have access to bit_cast here.
Review URL: http://codereview.chromium.org/10914 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5414 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port/platform')
-rw-r--r--webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp b/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp
index be21351..7871f60 100644
--- a/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp
+++ b/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp
@@ -86,10 +86,17 @@ bool FontPlatformData::operator==(const FontPlatformData& a) const
unsigned FontPlatformData::hash() const
{
- // This is taken from Android code. It is not our fault.
+ // This hash is taken from Android code. It is not our fault.
unsigned h = SkTypeface::UniqueID(m_typeface);
h ^= 0x01010101 * (((int)m_fakeBold << 1) | (int)m_fakeItalic);
- h ^= *reinterpret_cast<const uint32_t *>(&m_textSize);
+
+ // This memcpy is to avoid a reinterpret_cast that breaks strict-aliasing
+ // rules. See base/basictypes.h and its discussion of bit_cast for
+ // performance implications (briefly: doesn't matter).
+ uint32_t textsize_bytes;
+ memcpy(&textsize_bytes, &m_textSize, sizeof(uint32_t));
+ h ^= textsize_bytes;
+
return h;
}