OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 } | 79 } |
80 | 80 |
81 const UChar* characters16() const | 81 const UChar* characters16() const |
82 { | 82 { |
83 if (!m_impl) | 83 if (!m_impl) |
84 return 0; | 84 return 0; |
85 ASSERT(!is8Bit()); | 85 ASSERT(!is8Bit()); |
86 return m_impl->characters16() + m_offset; | 86 return m_impl->characters16() + m_offset; |
87 } | 87 } |
88 | 88 |
89 PassRefPtr<StringImpl> toString() const | |
90 { | |
91 if (!m_impl) | |
92 return m_impl; | |
93 if (m_impl->is8Bit()) | |
94 return StringImpl::create(characters8(), m_length); | |
95 return StringImpl::create(characters16(), m_length); | |
abarth-chromium
2013/09/20 21:13:34
We should probably add an optimization when m_offs
| |
96 } | |
97 | |
89 private: | 98 private: |
90 RefPtr<StringImpl> m_impl; | 99 RefPtr<StringImpl> m_impl; |
91 unsigned m_offset; | 100 unsigned m_offset; |
92 unsigned m_length; | 101 unsigned m_length; |
93 }; | 102 }; |
94 | 103 |
95 } | 104 } |
96 | 105 |
97 using WTF::StringView; | 106 using WTF::StringView; |
98 | 107 |
99 #endif | 108 #endif |
OLD | NEW |