OLD | NEW |
1 // Copyright (c) 2011, 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 /** | 5 /** |
6 * [StringBase] contains common methods used by concrete String implementations, | 6 * [StringBase] contains common methods used by concrete String implementations, |
7 * e.g., OneByteString. | 7 * e.g., OneByteString. |
8 */ | 8 */ |
9 class StringBase { | 9 class StringBase { |
10 | 10 |
11 factory StringBase._uninstantiable() { | 11 factory StringBase._uninstantiable() { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 if (this.substringMatches(index, other)) { | 120 if (this.substringMatches(index, other)) { |
121 return index; | 121 return index; |
122 } | 122 } |
123 } | 123 } |
124 return -1; | 124 return -1; |
125 } | 125 } |
126 | 126 |
127 int lastIndexOf(String other, [int start = null]) { | 127 int lastIndexOf(String other, [int start = null]) { |
128 if (start == null) start = length - 1; | 128 if (start == null) start = length - 1; |
129 if (other.isEmpty()) { | 129 if (other.isEmpty()) { |
130 return Math.min(this.length, start); | 130 return min(this.length, start); |
131 } | 131 } |
132 if (start >= this.length) { | 132 if (start >= this.length) { |
133 start = this.length - 1; | 133 start = this.length - 1; |
134 } | 134 } |
135 for (int index = start; index >= 0; index--) { | 135 for (int index = start; index >= 0; index--) { |
136 if (this.substringMatches(index, other)) { | 136 if (this.substringMatches(index, other)) { |
137 return index; | 137 return index; |
138 } | 138 } |
139 } | 139 } |
140 return -1; | 140 return -1; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 for (int g in groups) { | 497 for (int g in groups) { |
498 result.add(group(g)); | 498 result.add(group(g)); |
499 } | 499 } |
500 return result; | 500 return result; |
501 } | 501 } |
502 | 502 |
503 final int _start; | 503 final int _start; |
504 final String str; | 504 final String str; |
505 final String pattern; | 505 final String pattern; |
506 } | 506 } |
OLD | NEW |