| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * | 3 * |
| 4 * Copyright (C) 1999-2011, International Business Machines | 4 * Copyright (C) 1999-2014, International Business Machines |
| 5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
| 6 * | 6 * |
| 7 ******************************************************************************* | 7 ******************************************************************************* |
| 8 * file name: unistr_case.cpp | 8 * file name: unistr_case.cpp |
| 9 * encoding: US-ASCII | 9 * encoding: US-ASCII |
| 10 * tab size: 8 (not used) | 10 * tab size: 8 (not used) |
| 11 * indentation:2 | 11 * indentation:2 |
| 12 * | 12 * |
| 13 * created on: 2004aug19 | 13 * created on: 2004aug19 |
| 14 * created by: Markus W. Scherer | 14 * created by: Markus W. Scherer |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 | 94 |
| 95 // We need to allocate a new buffer for the internal string case mapping funct
ion. | 95 // We need to allocate a new buffer for the internal string case mapping funct
ion. |
| 96 // This is very similar to how doReplace() keeps the old array pointer | 96 // This is very similar to how doReplace() keeps the old array pointer |
| 97 // and deletes the old array itself after it is done. | 97 // and deletes the old array itself after it is done. |
| 98 // In addition, we are forcing cloneArrayIfNeeded() to always allocate a new a
rray. | 98 // In addition, we are forcing cloneArrayIfNeeded() to always allocate a new a
rray. |
| 99 UChar oldStackBuffer[US_STACKBUF_SIZE]; | 99 UChar oldStackBuffer[US_STACKBUF_SIZE]; |
| 100 UChar *oldArray; | 100 UChar *oldArray; |
| 101 int32_t oldLength; | 101 int32_t oldLength; |
| 102 | 102 |
| 103 if(fFlags&kUsingStackBuffer) { | 103 if(fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) { |
| 104 // copy the stack buffer contents because it will be overwritten | 104 // copy the stack buffer contents because it will be overwritten |
| 105 u_memcpy(oldStackBuffer, fUnion.fStackBuffer, fShortLength); | |
| 106 oldArray = oldStackBuffer; | 105 oldArray = oldStackBuffer; |
| 107 oldLength = fShortLength; | 106 oldLength = getShortLength(); |
| 107 u_memcpy(oldStackBuffer, fUnion.fStackFields.fBuffer, oldLength); |
| 108 } else { | 108 } else { |
| 109 oldArray = getArrayStart(); | 109 oldArray = getArrayStart(); |
| 110 oldLength = length(); | 110 oldLength = length(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 int32_t capacity; | 113 int32_t capacity; |
| 114 if(oldLength <= US_STACKBUF_SIZE) { | 114 if(oldLength <= US_STACKBUF_SIZE) { |
| 115 capacity = US_STACKBUF_SIZE; | 115 capacity = US_STACKBUF_SIZE; |
| 116 } else { | 116 } else { |
| 117 capacity = oldLength + 20; | 117 capacity = oldLength + 20; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 const UnicodeString *str1 = (const UnicodeString*) key1.pointer; | 171 const UnicodeString *str1 = (const UnicodeString*) key1.pointer; |
| 172 const UnicodeString *str2 = (const UnicodeString*) key2.pointer; | 172 const UnicodeString *str2 = (const UnicodeString*) key2.pointer; |
| 173 if (str1 == str2) { | 173 if (str1 == str2) { |
| 174 return TRUE; | 174 return TRUE; |
| 175 } | 175 } |
| 176 if (str1 == NULL || str2 == NULL) { | 176 if (str1 == NULL || str2 == NULL) { |
| 177 return FALSE; | 177 return FALSE; |
| 178 } | 178 } |
| 179 return str1->caseCompare(*str2, U_FOLD_CASE_DEFAULT) == 0; | 179 return str1->caseCompare(*str2, U_FOLD_CASE_DEFAULT) == 0; |
| 180 } | 180 } |
| OLD | NEW |