mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
use loop instead of while iterator in UString::ascii()
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
473fbb8e3b
commit
f1a9262ae2
1 changed files with 5 additions and 10 deletions
15
src/3rdparty/javascriptcore/runtime/UString.cpp
vendored
15
src/3rdparty/javascriptcore/runtime/UString.cpp
vendored
|
@ -346,19 +346,14 @@ char* UString::ascii() const
|
|||
static char* asciiBuffer = 0;
|
||||
|
||||
int length = size();
|
||||
int neededSize = length + 1;
|
||||
delete[] asciiBuffer;
|
||||
asciiBuffer = new char[neededSize];
|
||||
asciiBuffer = new char[length + 1];
|
||||
|
||||
const UChar* p = data();
|
||||
char* q = asciiBuffer;
|
||||
const UChar* limit = p + length;
|
||||
while (p != limit) {
|
||||
*q = static_cast<char>(p[0]);
|
||||
++p;
|
||||
++q;
|
||||
const UChar* d = data();
|
||||
for (int i = 0; i < length; i++) {
|
||||
asciiBuffer[i] = static_cast<char>(d[i]);
|
||||
}
|
||||
*q = '\0';
|
||||
asciiBuffer[length] = '\0';
|
||||
|
||||
return asciiBuffer;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue