Reviewed by Geoff Garen.
- make BaseStrings have themselves as a base, instead of nothing, to remove common branches
~0.7% SunSpider speedup
* runtime/UString.h:
(JSC::UString::Rep::Rep): For the constructor without a base, set self as base instead of null.
(JSC::UString::Rep::baseString): Just read m_baseString - no more branching.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@43090
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2009-04-30 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Geoff Garen.
+
+ - make BaseStrings have themselves as a base, instead of nothing, to remove common branches
+
+ ~0.7% SunSpider speedup
+
+ * runtime/UString.h:
+ (JSC::UString::Rep::Rep): For the constructor without a base, set self as base instead of null.
+ (JSC::UString::Rep::baseString): Just read m_baseString - no more branching.
+
2009-04-30 Gavin Barraclough <barraclough@apple.com>
Reviewed by Oliver Hunt.
static BaseString& empty() { return *emptyBaseString; }
protected:
+ // constructor for use by BaseString subclass; they are their own bases
Rep(int length)
: offset(0)
, len(length)
, rc(1)
, _hash(0)
- , m_nothing(0)
+ , m_baseString(static_cast<BaseString*>(this))
{
}
checkConsistency();
}
- union {
- // If !baseIsSelf()
- BaseString* m_baseString;
- // If baseIsSelf()
- void* m_nothing;
- };
+
+ BaseString* m_baseString;
private:
// For SmallStringStorage which allocates an array and does initialization manually.
inline UString::BaseString* UString::Rep::baseString()
{
- return baseIsSelf() ? reinterpret_cast<BaseString*>(this) : m_baseString;
+ return m_baseString;
}
inline const UString::BaseString* UString::Rep::baseString() const
{
- return const_cast<Rep*>(this)->baseString();
+ return m_baseString;
}
#ifdef NDEBUG