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

Unified Diff: runtime/vm/bit_vector.cc

Issue 10914314: Simple redundant load elimination. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
Index: runtime/vm/bit_vector.cc
===================================================================
--- runtime/vm/bit_vector.cc (revision 12420)
+++ runtime/vm/bit_vector.cc (working copy)
@@ -33,6 +33,14 @@
}
+bool BitVector::Equals(const BitVector& other) const {
+ for (int i = 0; i < data_length_; i++) {
+ if (data_[i] != other.data_[i]) return false;
+ }
+ return true;
+}
+
+
bool BitVector::AddAll(BitVector* from) {
ASSERT(data_length_ == from->data_length_);
bool changed = false;
@@ -60,4 +68,25 @@
}
+bool BitVector::Intersect(const BitVector& other) {
Kevin Millikin (Google) 2012/09/17 12:09:47 It doesn't look like you use the return value, so
Florian Schneider 2012/09/17 14:20:59 Done.
+ ASSERT(other.length() == length());
+ bool changed = false;
+ for (int i = 0; i < data_length_; i++) {
+ const uword before = data_[i];
+ const uword after = data_[i] & other.data_[i];
+ if (before != after) changed = true;
+ data_[i] = after;
+ }
+ return changed;
+}
+
+
+void BitVector::Print() const {
+ OS::Print("[");
+ for (intptr_t i = 0; i < length_; i++) {
+ OS::Print(Contains(i) ? "1" : "0");
+ }
+ OS::Print("]");
+}
+
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698