Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: samples/third_party/dromaeo/common/BenchUtil.dart

Issue 12473003: Remove deprecated StringBuffer.add, addAll and addCharCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 part of common; 5 part of common;
6 6
7 // Misc benchmark-related utility functions. 7 // Misc benchmark-related utility functions.
8 8
9 class BenchUtil { 9 class BenchUtil {
10 static int get now { 10 static int get now {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 static String encodeUri(final String s) { 50 static String encodeUri(final String s) {
51 StringBuffer sb = new StringBuffer(); 51 StringBuffer sb = new StringBuffer();
52 for (int i = 0; i < s.length; i++) { 52 for (int i = 0; i < s.length; i++) {
53 final int charCode = s.codeUnitAt(i); 53 final int charCode = s.codeUnitAt(i);
54 final bool noEscape = 54 final bool noEscape =
55 _inRange(charCode, '0', '9') || 55 _inRange(charCode, '0', '9') ||
56 _inRange(charCode, 'a', 'z') || 56 _inRange(charCode, 'a', 'z') ||
57 _inRange(charCode, 'A', 'Z'); 57 _inRange(charCode, 'A', 'Z');
58 if (noEscape) { 58 if (noEscape) {
59 sb.add(s[i]); 59 sb.write(s[i]);
60 } else { 60 } else {
61 sb.add('%'); 61 sb.write('%');
62 sb.add(_asDigit((charCode >> 4) & 0xF)); 62 sb.write(_asDigit((charCode >> 4) & 0xF));
63 sb.add(_asDigit(charCode & 0xF)); 63 sb.write(_asDigit(charCode & 0xF));
64 } 64 }
65 } 65 }
66 return sb.toString(); 66 return sb.toString();
67 } 67 }
68 68
69 // TODO: use corelib implementation. 69 // TODO: use corelib implementation.
70 static String replaceAll(String s, String pattern, 70 static String replaceAll(String s, String pattern,
71 String replacement(Match match)) { 71 String replacement(Match match)) {
72 StringBuffer sb = new StringBuffer(); 72 StringBuffer sb = new StringBuffer();
73 73
74 int pos = 0; 74 int pos = 0;
75 for (Match match in new RegExp(pattern).allMatches(s)) { 75 for (Match match in new RegExp(pattern).allMatches(s)) {
76 sb.add(s.substring(pos, match.start)); 76 sb.write(s.substring(pos, match.start));
77 sb.add(replacement(match)); 77 sb.write(replacement(match));
78 pos = match.end; 78 pos = match.end;
79 } 79 }
80 sb.add(s.substring(pos)); 80 sb.write(s.substring(pos));
81 81
82 return sb.toString(); 82 return sb.toString();
83 } 83 }
84 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698