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

Side by Side Diff: tests/language/string_charcode_test.dart

Issue 105143011: Optimize one byte string comparisons. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4 // VMOptions=--optimization-counter-threshold=10 --no-use-osr
5
6 import "package:expect/expect.dart";
7
8 main() {
9 for (int i = 0; i < 20; i++) {
10 Expect.isTrue(moo("x"));
11 Expect.isFalse(moo("X"));
12 Expect.isFalse(moo("xx"));
13 Expect.isTrue(mooRev("x"));
14 Expect.isFalse(mooRev("X"));
15 Expect.isFalse(mooRev("xx"));
16 Expect.isTrue(goo("Hello", "e"));
17 Expect.isFalse(goo("Hello", "E"));
18 Expect.isFalse(goo("Hello", "ee"));
19 Expect.isTrue(gooRev("Hello", "e"));
20 Expect.isFalse(gooRev("Hello", "E"));
21 Expect.isFalse(gooRev("Hello", "ee"));
22 Expect.isTrue(hoo("HH"));
23 Expect.isFalse(hoo("Ha"));
24 Expect.isTrue(hooRev("HH"));
25 Expect.isFalse(hooRev("Ha"));
26 }
27 Expect.isFalse(moo(12));
28 Expect.isFalse(mooRev(12));
29 Expect.isTrue(goo([1, 2], 2));
30 Expect.isTrue(gooRev([1, 2], 2));
31 Expect.throws(() => hoo("H"), (e) => e is RangeError);
32 Expect.throws(() => hooRev("H"), (e) => e is RangeError);
33 }
34
35 moo(j) {
36 return "x" == j;
37 }
38
39 goo(a, j) {
40 return a[1] == j;
41 }
42
43 // Check constant folding.
44 hoo(a) {
45 return a[1] == ("Hello")[0];
46 }
47
48 mooRev(j) {
49 return j == "x";
50 }
51
52 gooRev(a, j) {
53 return j == a[1];
54 }
55
56 // Check constant folding.
57 hooRev(a) {
58 return ("Hello")[0] == a[1];
59 }
60
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698