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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 22842014: Fold equals and not equals comparisons for constant strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index 4841d52bf78706b067438d41f7a89f1c3271d31d..5e4ebf78f294ff112d3353f0917e45fa10681bcf 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -6051,8 +6051,8 @@ void ConstantPropagator::VisitEqualityCompare(EqualityCompareInstr* instr) {
RawObject::IsIntegerClassId(instr->operation_cid())) {
return SetValue(instr,
(instr->kind() == Token::kEQ)
- ? Bool::True()
- : Bool::False());
+ ? Bool::True()
+ : Bool::False());
}
}
@@ -6064,6 +6064,12 @@ void ConstantPropagator::VisitEqualityCompare(EqualityCompareInstr* instr) {
Integer::Cast(left),
Integer::Cast(right));
SetValue(instr, result ? Bool::True() : Bool::False());
+ } else if (left.IsString() && right.IsString()) {
srdjan 2013/08/26 16:00:39 I believe all constant strings must be canonicaliz
+ const bool result = String::Cast(left).Equals(String::Cast(right));
+ SetValue(instr,
+ ((instr->kind() == Token::kEQ) == result)
+ ? Bool::True()
+ : Bool::False());
} else {
SetValue(instr, non_constant_);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698