Changeset 54545 in webkit for trunk/JavaScriptCore/runtime/UString.cpp
- Timestamp:
- Feb 9, 2010, 3:55:39 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/UString.cpp
r54531 r54545 54 54 55 55 namespace JSC { 56 56 57 57 extern const double NaN; 58 58 extern const double Inf; … … 147 147 } 148 148 149 // These static strings are immutable, except for rc, whose initial value is chosen to 149 // These static strings are immutable, except for rc, whose initial value is chosen to 150 150 // reduce the possibility of it becoming zero due to ref/deref not being thread-safe. 151 151 static UChar sharedEmptyChar; … … 175 175 UString::UString(const UChar* c, int length) 176 176 { 177 if (length == 0) 177 if (length == 0) 178 178 m_rep = &Rep::empty(); 179 179 else … … 181 181 } 182 182 183 UString UString::createFromUTF8(const char* string)184 {185 if (!string)186 return null();187 188 size_t length = strlen(string);189 Vector<UChar, 1024> buffer(length);190 UChar* p = buffer.data();191 if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length))192 return null();193 194 return UString(buffer.data(), p - buffer.data());195 }196 197 183 UString UString::from(int i) 198 184 { … … 200 186 UChar* end = buf + sizeof(buf) / sizeof(UChar); 201 187 UChar* p = end; 202 188 203 189 if (i == 0) 204 190 *--p = '0'; … … 262 248 UChar* end = buf + sizeof(buf) / sizeof(UChar); 263 249 UChar* p = end; 264 250 265 251 if (u == 0) 266 252 *--p = '0'; … … 271 257 } 272 258 } 273 259 274 260 return UString(p, static_cast<int>(end - p)); 275 261 } … … 598 584 return static_cast<int>(c - data()); 599 585 } 600 586 601 587 return -1; 602 588 }
Note:
See TracChangeset
for help on using the changeset viewer.