OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Misc benchmark-related utility functions. | 5 // Misc benchmark-related utility functions. |
6 | 6 |
7 class BenchUtil { | 7 class BenchUtil { |
8 static int get now { | 8 static int get now { |
9 return new Date.now().millisecondsSinceEpoch; | 9 return new Date.now().millisecondsSinceEpoch; |
10 } | 10 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 return sb.toString(); | 64 return sb.toString(); |
65 } | 65 } |
66 | 66 |
67 // TODO: use corelib implementation. | 67 // TODO: use corelib implementation. |
68 static String replaceAll(String s, String pattern, | 68 static String replaceAll(String s, String pattern, |
69 String replacement(Match match)) { | 69 String replacement(Match match)) { |
70 StringBuffer sb = new StringBuffer(); | 70 StringBuffer sb = new StringBuffer(); |
71 | 71 |
72 int pos = 0; | 72 int pos = 0; |
73 for (Match match in new RegExp(pattern).allMatches(s)) { | 73 for (Match match in new RegExp(pattern).allMatches(s)) { |
74 sb.add(s.substring(pos, match.start())); | 74 sb.add(s.substring(pos, match.start)); |
75 sb.add(replacement(match)); | 75 sb.add(replacement(match)); |
76 pos = match.end(); | 76 pos = match.end; |
77 } | 77 } |
78 sb.add(s.substring(pos)); | 78 sb.add(s.substring(pos)); |
79 | 79 |
80 return sb.toString(); | 80 return sb.toString(); |
81 } | 81 } |
82 } | 82 } |
OLD | NEW |