Changeset 11739 in webkit for trunk/JavaScriptCore/kjs/identifier.cpp
- Timestamp:
- Dec 22, 2005, 5:52:43 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/identifier.cpp
r11684 r11739 99 99 } 100 100 101 inline unsigned hash(const char* const& c) 102 { 103 return UString::Rep::computeHash(c); 104 } 105 106 inline bool equal(UString::Rep* const& r, const char* const& s) 107 { 108 return Identifier::equal(r, s); 109 } 110 111 inline UString::Rep *convert(const char* const& c, unsigned hash) 112 { 113 int length = strlen(c); 114 UChar *d = static_cast<UChar *>(fastMalloc(sizeof(UChar) * length)); 115 for (int i = 0; i != length; i++) 116 d[i] = c[i]; 117 118 UString::Rep *r = UString::Rep::create(d, length).release(); 119 r->isIdentifier = 1; 120 r->rc = 0; 121 r->_hash = hash; 122 123 return r; 124 } 101 struct CStringTranslator 102 { 103 static unsigned hash(const char *c) 104 { 105 return UString::Rep::computeHash(c); 106 } 107 108 static bool equal(UString::Rep *r, const char *s) 109 { 110 return Identifier::equal(r, s); 111 } 112 113 static void translate(UString::Rep*& location, const char *c, unsigned hash) 114 { 115 int length = strlen(c); 116 UChar *d = static_cast<UChar *>(fastMalloc(sizeof(UChar) * length)); 117 for (int i = 0; i != length; i++) 118 d[i] = c[i]; 119 120 UString::Rep *r = UString::Rep::create(d, length).release(); 121 r->isIdentifier = 1; 122 r->rc = 0; 123 r->_hash = hash; 124 125 location = r; 126 } 127 }; 125 128 126 129 PassRefPtr<UString::Rep> Identifier::add(const char *c) … … 132 135 return pass(&UString::Rep::empty); 133 136 134 return pass(*identifierTable().insert<const char *, hash, KJS::equal, convert>(c).first);137 return pass(*identifierTable().insert<const char *, CStringTranslator>(c).first); 135 138 } 136 139 … … 140 143 }; 141 144 142 inline unsigned hash(const UCharBuffer& buf) 143 { 144 return UString::Rep::computeHash(buf.s, buf.length); 145 } 146 147 inline bool equal(UString::Rep* const& str, const UCharBuffer& buf) 148 { 149 return Identifier::equal(str, buf.s, buf.length); 150 } 151 152 inline UString::Rep *convert(const UCharBuffer& buf, unsigned hash) 153 { 154 UChar *d = static_cast<UChar *>(fastMalloc(sizeof(UChar) * buf.length)); 155 for (unsigned i = 0; i != buf.length; i++) 156 d[i] = buf.s[i]; 157 158 UString::Rep *r = UString::Rep::create(d, buf.length).release(); 159 r->isIdentifier = 1; 160 r->rc = 0; 161 r->_hash = hash; 162 163 return r; 164 } 145 struct UCharBufferTranslator 146 { 147 static unsigned hash(const UCharBuffer& buf) 148 { 149 return UString::Rep::computeHash(buf.s, buf.length); 150 } 151 152 static bool equal(UString::Rep *str, const UCharBuffer& buf) 153 { 154 return Identifier::equal(str, buf.s, buf.length); 155 } 156 157 static void translate(UString::Rep *& location, const UCharBuffer& buf, unsigned hash) 158 { 159 UChar *d = static_cast<UChar *>(fastMalloc(sizeof(UChar) * buf.length)); 160 for (unsigned i = 0; i != buf.length; i++) 161 d[i] = buf.s[i]; 162 163 UString::Rep *r = UString::Rep::create(d, buf.length).release(); 164 r->isIdentifier = 1; 165 r->rc = 0; 166 r->_hash = hash; 167 168 location = r; 169 } 170 }; 165 171 166 172 PassRefPtr<UString::Rep> Identifier::add(const UChar *s, int length) … … 170 176 171 177 UCharBuffer buf = {s, length}; 172 return pass(*identifierTable().insert<UCharBuffer, hash, KJS::equal, convert>(buf).first);178 return pass(*identifierTable().insert<UCharBuffer, UCharBufferTranslator>(buf).first); 173 179 } 174 180
Note:
See TracChangeset
for help on using the changeset viewer.