Ignore:
Timestamp:
Apr 30, 2009, 2:18:31 PM (16 years ago)
Author:
[email protected]
Message:

2009-04-30 Maciej Stachowiak <[email protected]>

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/UString.h

    r42680 r43090  
    134134
    135135        protected:
     136            // constructor for use by BaseString subclass; they are their own bases
    136137            Rep(int length)
    137138                : offset(0)
     
    139140                , rc(1)
    140141                , _hash(0)
    141                 , m_nothing(0)
     142                , m_baseString(static_cast<BaseString*>(this))
    142143            {
    143144            }
     
    153154            }
    154155
    155             union {
    156                 // If !baseIsSelf()
    157                 BaseString* m_baseString;
    158                 // If baseIsSelf()
    159                 void* m_nothing;
    160             };
     156
     157            BaseString* m_baseString;
    161158
    162159        private:
     
    411408    inline UString::BaseString* UString::Rep::baseString()
    412409    {
    413         return baseIsSelf() ? reinterpret_cast<BaseString*>(this) : m_baseString;
     410        return m_baseString;
    414411    }
    415412
    416413    inline const UString::BaseString* UString::Rep::baseString() const
    417414    {
    418         return const_cast<Rep*>(this)->baseString();
     415        return m_baseString;
    419416    }
    420417
Note: See TracChangeset for help on using the changeset viewer.