| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights
reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights
reserved. |
| 4 * Copyright (C) 2007-2009 Torch Mobile, Inc. | 4 * Copyright (C) 2007-2009 Torch Mobile, Inc. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 | 564 |
| 565 String String::isolatedCopy() const | 565 String String::isolatedCopy() const |
| 566 { | 566 { |
| 567 if (!m_impl) | 567 if (!m_impl) |
| 568 return String(); | 568 return String(); |
| 569 return m_impl->isolatedCopy(); | 569 return m_impl->isolatedCopy(); |
| 570 } | 570 } |
| 571 | 571 |
| 572 bool String::isSafeToSendToAnotherThread() const | 572 bool String::isSafeToSendToAnotherThread() const |
| 573 { | 573 { |
| 574 if (!impl()) | 574 return !m_impl || m_impl->isSafeToSendToAnotherThread(); |
| 575 return true; | |
| 576 if (impl()->isStatic()) | |
| 577 return true; | |
| 578 // AtomicStrings are not safe to send between threads as ~StringImpl() | |
| 579 // will try to remove them from the wrong AtomicStringTable. | |
| 580 if (impl()->isAtomic()) | |
| 581 return false; | |
| 582 if (impl()->hasOneRef()) | |
| 583 return true; | |
| 584 return false; | |
| 585 } | 575 } |
| 586 | 576 |
| 587 void String::split(const String& separator, bool allowEmptyEntries, Vector<Strin
g>& result) const | 577 void String::split(const String& separator, bool allowEmptyEntries, Vector<Strin
g>& result) const |
| 588 { | 578 { |
| 589 result.clear(); | 579 result.clear(); |
| 590 | 580 |
| 591 unsigned startPos = 0; | 581 unsigned startPos = 0; |
| 592 size_t endPos; | 582 size_t endPos; |
| 593 while ((endPos = find(separator, startPos)) != kNotFound) { | 583 while ((endPos = find(separator, startPos)) != kNotFound) { |
| 594 if (allowEmptyEntries || startPos != endPos) | 584 if (allowEmptyEntries || startPos != endPos) |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 buffer.append('\0'); | 926 buffer.append('\0'); |
| 937 return buffer; | 927 return buffer; |
| 938 } | 928 } |
| 939 | 929 |
| 940 Vector<char> asciiDebug(String& string) | 930 Vector<char> asciiDebug(String& string) |
| 941 { | 931 { |
| 942 return asciiDebug(string.impl()); | 932 return asciiDebug(string.impl()); |
| 943 } | 933 } |
| 944 | 934 |
| 945 #endif | 935 #endif |
| OLD | NEW |