Changeset 35898 in webkit for trunk/JavaScriptCore/kjs/identifier.cpp
- Timestamp:
- Aug 22, 2008, 8:17:17 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/identifier.cpp
r35776 r35898 20 20 21 21 #include "config.h" 22 23 22 #include "identifier.h" 24 23 … … 77 76 } 78 77 79 bool Identifier::equal(const UString::Rep *r, const char *s)78 bool Identifier::equal(const UString::Rep* r, const char* s) 80 79 { 81 80 int length = r->len; 82 const UChar *d = r->data();81 const UChar* d = r->data(); 83 82 for (int i = 0; i != length; ++i) 84 83 if (d[i] != (unsigned char)s[i]) … … 87 86 } 88 87 89 bool Identifier::equal(const UString::Rep *r, const UChar *s, int length)88 bool Identifier::equal(const UString::Rep* r, const UChar* s, int length) 90 89 { 91 90 if (r->len != length) 92 91 return false; 93 const UChar *d = r->data();92 const UChar* d = r->data(); 94 93 for (int i = 0; i != length; ++i) 95 94 if (d[i] != s[i]) … … 100 99 struct CStringTranslator 101 100 { 102 static unsigned hash(const char *c)101 static unsigned hash(const char* c) 103 102 { 104 103 return UString::Rep::computeHash(c); 105 104 } 106 105 107 static bool equal(UString::Rep *r, const char *s)106 static bool equal(UString::Rep* r, const char* s) 108 107 { 109 108 return Identifier::equal(r, s); 110 109 } 111 110 112 static void translate(UString::Rep*& location, const char *c, unsigned hash)111 static void translate(UString::Rep*& location, const char* c, unsigned hash) 113 112 { 114 113 size_t length = strlen(c); 115 UChar *d = static_cast<UChar*>(fastMalloc(sizeof(UChar) * length));114 UChar* d = static_cast<UChar*>(fastMalloc(sizeof(UChar) * length)); 116 115 for (size_t i = 0; i != length; i++) 117 116 d[i] = static_cast<unsigned char>(c[i]); // use unsigned char to zero-extend instead of sign-extend 118 117 119 UString::Rep *r = UString::Rep::create(d, static_cast<int>(length)).releaseRef();118 UString::Rep* r = UString::Rep::create(d, static_cast<int>(length)).releaseRef(); 120 119 r->rc = 0; 121 120 r->_hash = hash; … … 156 155 157 156 struct UCharBuffer { 158 const UChar *s;157 const UChar* s; 159 158 unsigned int length; 160 159 }; … … 167 166 } 168 167 169 static bool equal(UString::Rep *str, const UCharBuffer& buf)168 static bool equal(UString::Rep* str, const UCharBuffer& buf) 170 169 { 171 170 return Identifier::equal(str, buf.s, buf.length); 172 171 } 173 172 174 static void translate(UString::Rep 175 { 176 UChar *d = static_cast<UChar*>(fastMalloc(sizeof(UChar) * buf.length));173 static void translate(UString::Rep*& location, const UCharBuffer& buf, unsigned hash) 174 { 175 UChar* d = static_cast<UChar*>(fastMalloc(sizeof(UChar) * buf.length)); 177 176 for (unsigned i = 0; i != buf.length; i++) 178 177 d[i] = buf.s[i]; 179 178 180 UString::Rep *r = UString::Rep::create(d, buf.length).releaseRef();179 UString::Rep* r = UString::Rep::create(d, buf.length).releaseRef(); 181 180 r->rc = 0; 182 181 r->_hash = hash; … … 219 218 } 220 219 221 void Identifier::remove(UString::Rep *r)220 void Identifier::remove(UString::Rep* r) 222 221 { 223 222 r->identifierTable()->remove(r);
Note:
See TracChangeset
for help on using the changeset viewer.