[webkit-dev] Slow idioms with WTF::String

Rob Buis rwlbuis at gmail.com
Tue Jul 12 16:16:24 PDT 2011

Hi Yong,

On 12 July 2011 18:10, Yong Li <yong.li.webkit at gmail.com> wrote:
> Another slow case is converting a const C string to WTF::String every
> time. For example,
>    return (m_httpHeaderFields.contains("If-Match") ||
>            m_httpHeaderFields.contains("If-Modified-Since") ||
>            m_httpHeaderFields.contains("If-None-Match") ||
>            m_httpHeaderFields.contains("If-Range") ||
>            m_httpHeaderFields.contains("If-Unmodified-Since"));
> This function creates 5 Strings (calls fastMalloc 5 times), and also
> calculates the hash key 5 times, and then throws them away.

In this case, the code already indicates it is not optimal:

// Alternate accessors that are faster than converting the char* to
AtomicString first.
bool contains(const char*) const;

Also this converting can probably be fixed by using


More information about the webkit-dev mailing list