OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 m_is8Bit = other.m_string.is8Bit(); | 59 m_is8Bit = other.m_string.is8Bit(); |
60 return; | 60 return; |
61 } | 61 } |
62 | 62 |
63 if (other.is8Bit()) | 63 if (other.is8Bit()) |
64 append(other.characters8(), other.m_length); | 64 append(other.characters8(), other.m_length); |
65 else | 65 else |
66 append(other.characters16(), other.m_length); | 66 append(other.characters16(), other.m_length); |
67 } | 67 } |
68 | 68 |
69 // NOTE: The semantics of this are different than StringView(..., offset, leng
th) | 69 // NOTE: The semantics of this are different than StringView(..., offset, |
70 // in that an invalid offset or invalid length is a no-op instead of an | 70 // length) in that an invalid offset or invalid length is a no-op instead of |
71 // error. | 71 // an error. |
72 // TODO(esprehn): We should probably unify the semantics instead. | 72 // TODO(esprehn): We should probably unify the semantics instead. |
73 void append(const StringView& string, unsigned offset, unsigned length) { | 73 void append(const StringView& string, unsigned offset, unsigned length) { |
74 unsigned extent = offset + length; | 74 unsigned extent = offset + length; |
75 if (extent < offset || extent > string.length()) | 75 if (extent < offset || extent > string.length()) |
76 return; | 76 return; |
77 | 77 |
78 // We can't do this before the above check since StringView's constructor | 78 // We can't do this before the above check since StringView's constructor |
79 // doesn't accept invalid offsets or lengths. | 79 // doesn't accept invalid offsets or lengths. |
80 append(StringView(string, offset, length)); | 80 append(StringView(string, offset, length)); |
81 } | 81 } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 307 } |
308 inline bool operator!=(const String& a, const StringBuilder& b) { | 308 inline bool operator!=(const String& a, const StringBuilder& b) { |
309 return !equal(b, a); | 309 return !equal(b, a); |
310 } | 310 } |
311 | 311 |
312 } // namespace WTF | 312 } // namespace WTF |
313 | 313 |
314 using WTF::StringBuilder; | 314 using WTF::StringBuilder; |
315 | 315 |
316 #endif // StringBuilder_h | 316 #endif // StringBuilder_h |
OLD | NEW |