Chromium Code Reviews| Index: pkg/front_end/lib/src/scanner/string_utilities.dart |
| diff --git a/pkg/front_end/lib/src/scanner/string_utilities.dart b/pkg/front_end/lib/src/scanner/string_utilities.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4f9dc14c1c79a33372ebf7363230d0189bed199c |
| --- /dev/null |
| +++ b/pkg/front_end/lib/src/scanner/string_utilities.dart |
| @@ -0,0 +1,28 @@ |
| +// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library front_end.src.scanner.string_utilities; |
| + |
| +import 'package:front_end/src/scanner/interner.dart'; |
| + |
| +class StringUtilities { |
| + static Interner INTERNER = new NullInterner(); |
| + |
| + static bool endsWith3(String str, int c1, int c2, int c3) { |
|
Brian Wilkerson
2016/11/08 20:53:24
We might want to verify that these methods are sti
|
| + var length = str.length; |
| + return length >= 3 && |
| + str.codeUnitAt(length - 3) == c1 && |
| + str.codeUnitAt(length - 2) == c2 && |
| + str.codeUnitAt(length - 1) == c3; |
| + } |
| + |
| + static String intern(String string) => INTERNER.intern(string); |
| + |
| + static bool startsWith3(String str, int start, int c1, int c2, int c3) { |
| + return str.length - start >= 3 && |
| + str.codeUnitAt(start) == c1 && |
| + str.codeUnitAt(start + 1) == c2 && |
| + str.codeUnitAt(start + 2) == c3; |
| + } |
| +} |