| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 const int _maxAscii = 0x7f; | 5 const int _maxAscii = 0x7f; |
| 6 const int _maxLatin1 = 0xff; | 6 const int _maxLatin1 = 0xff; |
| 7 const int _maxUtf16 = 0xffff; | 7 const int _maxUtf16 = 0xffff; |
| 8 const int _maxUnicode = 0x10ffff; | 8 const int _maxUnicode = 0x10ffff; |
| 9 | 9 |
| 10 patch class String { | 10 patch class String { |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 : pattern.allMatches(this, startIndex).iterator; | 572 : pattern.allMatches(this, startIndex).iterator; |
| 573 if (!iterator.moveNext()) return this; | 573 if (!iterator.moveNext()) return this; |
| 574 Match match = iterator.current; | 574 Match match = iterator.current; |
| 575 return replaceRange(match.start, match.end, replacement); | 575 return replaceRange(match.start, match.end, replacement); |
| 576 } | 576 } |
| 577 | 577 |
| 578 String replaceRange(int start, int end, String replacement) { | 578 String replaceRange(int start, int end, String replacement) { |
| 579 int length = this.length; | 579 int length = this.length; |
| 580 end = RangeError.checkValidRange(start, end, length); | 580 end = RangeError.checkValidRange(start, end, length); |
| 581 bool replacementIsOneByte = replacement._isOneByte; | 581 bool replacementIsOneByte = replacement._isOneByte; |
| 582 if (start == 0 && end == length) return replacement; |
| 582 int replacementLength = replacement.length; | 583 int replacementLength = replacement.length; |
| 583 int totalLength = start + (length - end) + replacementLength; | 584 int totalLength = start + (length - end) + replacementLength; |
| 584 if (replacementIsOneByte && this._isOneByte) { | 585 if (replacementIsOneByte && this._isOneByte) { |
| 585 var result = _OneByteString._allocate(totalLength); | 586 var result = _OneByteString._allocate(totalLength); |
| 586 int index = 0; | 587 int index = 0; |
| 587 index = result._setRange(index, this, 0, start); | 588 index = result._setRange(index, this, 0, start); |
| 588 index = result._setRange(start, replacement, 0, replacementLength); | 589 index = result._setRange(start, replacement, 0, replacementLength); |
| 589 result._setRange(index, this, end, length); | 590 result._setRange(index, this, end, length); |
| 590 return result; | 591 return result; |
| 591 } | 592 } |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 for (int g in groups) { | 1314 for (int g in groups) { |
| 1314 result.add(group(g)); | 1315 result.add(group(g)); |
| 1315 } | 1316 } |
| 1316 return result; | 1317 return result; |
| 1317 } | 1318 } |
| 1318 | 1319 |
| 1319 final int start; | 1320 final int start; |
| 1320 final String input; | 1321 final String input; |
| 1321 final String pattern; | 1322 final String pattern; |
| 1322 } | 1323 } |
| OLD | NEW |