| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) | 4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r
ights reserved. |
| 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 return newImpl.release(); | 599 return newImpl.release(); |
| 600 | 600 |
| 601 // Do a slower implementation for cases that include non-ASCII Latin-1 c
haracters. | 601 // Do a slower implementation for cases that include non-ASCII Latin-1 c
haracters. |
| 602 int numberSharpSCharacters = 0; | 602 int numberSharpSCharacters = 0; |
| 603 | 603 |
| 604 // There are two special cases. | 604 // There are two special cases. |
| 605 // 1. latin-1 characters when converted to upper case are 16 bit charac
ters. | 605 // 1. latin-1 characters when converted to upper case are 16 bit charac
ters. |
| 606 // 2. Lower case sharp-S converts to "SS" (two characters) | 606 // 2. Lower case sharp-S converts to "SS" (two characters) |
| 607 for (int32_t i = 0; i < length; ++i) { | 607 for (int32_t i = 0; i < length; ++i) { |
| 608 LChar c = characters8()[i]; | 608 LChar c = characters8()[i]; |
| 609 if (UNLIKELY(c == smallLetterSharpS)) | 609 if (UNLIKELY(c == smallLetterSharpSCharacter)) |
| 610 ++numberSharpSCharacters; | 610 ++numberSharpSCharacters; |
| 611 UChar upper = static_cast<UChar>(Unicode::toUpper(c)); | 611 UChar upper = static_cast<UChar>(Unicode::toUpper(c)); |
| 612 if (UNLIKELY(upper > 0xff)) { | 612 if (UNLIKELY(upper > 0xff)) { |
| 613 // Since this upper-cased character does not fit in an 8-bit str
ing, we need to take the 16-bit path. | 613 // Since this upper-cased character does not fit in an 8-bit str
ing, we need to take the 16-bit path. |
| 614 goto upconvert; | 614 goto upconvert; |
| 615 } | 615 } |
| 616 data8[i] = static_cast<LChar>(upper); | 616 data8[i] = static_cast<LChar>(upper); |
| 617 } | 617 } |
| 618 | 618 |
| 619 if (!numberSharpSCharacters) | 619 if (!numberSharpSCharacters) |
| 620 return newImpl.release(); | 620 return newImpl.release(); |
| 621 | 621 |
| 622 // We have numberSSCharacters sharp-s characters, but none of the other
special characters. | 622 // We have numberSSCharacters sharp-s characters, but none of the other
special characters. |
| 623 newImpl = createUninitialized(m_length + numberSharpSCharacters, data8); | 623 newImpl = createUninitialized(m_length + numberSharpSCharacters, data8); |
| 624 | 624 |
| 625 LChar* dest = data8; | 625 LChar* dest = data8; |
| 626 | 626 |
| 627 for (int32_t i = 0; i < length; ++i) { | 627 for (int32_t i = 0; i < length; ++i) { |
| 628 LChar c = characters8()[i]; | 628 LChar c = characters8()[i]; |
| 629 if (c == smallLetterSharpS) { | 629 if (c == smallLetterSharpSCharacter) { |
| 630 *dest++ = 'S'; | 630 *dest++ = 'S'; |
| 631 *dest++ = 'S'; | 631 *dest++ = 'S'; |
| 632 } else | 632 } else |
| 633 *dest++ = static_cast<LChar>(Unicode::toUpper(c)); | 633 *dest++ = static_cast<LChar>(Unicode::toUpper(c)); |
| 634 } | 634 } |
| 635 | 635 |
| 636 return newImpl.release(); | 636 return newImpl.release(); |
| 637 } | 637 } |
| 638 | 638 |
| 639 upconvert: | 639 upconvert: |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2088 | 2088 |
| 2089 size_t StringImpl::sizeInBytes() const | 2089 size_t StringImpl::sizeInBytes() const |
| 2090 { | 2090 { |
| 2091 size_t size = length(); | 2091 size_t size = length(); |
| 2092 if (!is8Bit()) | 2092 if (!is8Bit()) |
| 2093 size *= 2; | 2093 size *= 2; |
| 2094 return size + sizeof(*this); | 2094 return size + sizeof(*this); |
| 2095 } | 2095 } |
| 2096 | 2096 |
| 2097 } // namespace WTF | 2097 } // namespace WTF |
| OLD | NEW |