<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>115008</bug_id>
          
          <creation_ts>2013-04-22 19:41:28 -0700</creation_ts>
          <short_desc>Compute &quot;better&quot; hash for WTF::StringImpl::StringImpl(CreateEmptyUnique_T)</short_desc>
          <delta_ts>2013-04-22 19:41:28 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Template Framework</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Kilzer (:ddkilzer)">ddkilzer</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>benjamin</cc>
    
    <cc>darin</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>879564</commentid>
    <comment_count>0</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2013-04-22 19:41:28 -0700</bug_when>
    <thetext>Per comments in Bug 114970, we should compute a &quot;better&quot; hash in WTF::StringImpl::StringImpl(CreateEmptyUnique_T):

(In reply to Bug 114970 comment #2, Darin Adler wrote)
&gt; (From update of attachment 199053 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=199053&amp;action=review
&gt; 
&gt; &gt; Source/WTF/wtf/text/StringImpl.h:316
&gt; &gt; -        unsigned hash = reinterpret_cast&lt;uintptr_t&gt;(this);
&gt; &gt; +        unsigned hash = static_cast&lt;uint32_t&gt;(reinterpret_cast&lt;uintptr_t&gt;(this));
&gt; 
&gt; This is a silly approach to creating the hash. For example, the low bits will always be due to alignment zero. I suggest we use a random number instead.
&gt; 
&gt; Code change is OK, but code is dumb.

(In reply to Bug 114970 comment #6, David Kilzer wrote)
&gt; (In reply to Bug 114970 comment #2, Darin Adler wrote)
&gt; &gt; Code change is OK, but code is dumb.
&gt; 
&gt; Should we use WTF::intHash(uint32_t) on 32-bit platforms and WTF::intHas(uint64_t) on 64-bit platforms instead?

(In reply to Bug 114970 comment #7, Benjamin Poulain wrote)
&gt; (In reply to Bug 114970 comment #6, David Kilzer wrote)
&gt; &gt; Should we use WTF::intHash(uint32_t) on 32-bit platforms and WTF::intHas(uint64_t) on 64-bit platforms instead?
&gt; 
&gt; The only property needed for that hash is it should never equals the hash of emptyString().
&gt; 
&gt; We could basically use a constant here. Any number !m hash(empty()) has the same theoretical chances of conflicts.
&gt; 
&gt; I have been trying to kill this constructor every now and then :)

(In reply to Bug 114970 comment #8, Darin Adler wrote)
&gt; (In reply to Bug 114970 comment #7, Benjamin Poulain wrote)
&gt; &gt; The only property needed for that hash is it should never equals the hash of emptyString().
&gt; 
&gt; Maybe (hash(emptyString()) ^ 0x100) would work?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>