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

Side by Side Diff: runtime/vm/bit_vector.cc

Issue 18341023: Removes undefined shifting behavior from BitVector::Equals. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | 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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #include "vm/bit_vector.h" 5 #include "vm/bit_vector.h"
6 6
7 #include "vm/os.h" 7 #include "vm/os.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 23 matching lines...) Expand all
34 34
35 35
36 bool BitVector::Equals(const BitVector& other) const { 36 bool BitVector::Equals(const BitVector& other) const {
37 if (length_ != other.length_) return false; 37 if (length_ != other.length_) return false;
38 intptr_t i = 0; 38 intptr_t i = 0;
39 for (; i < data_length_ - 1; i++) { 39 for (; i < data_length_ - 1; i++) {
40 if (data_[i] != other.data_[i]) return false; 40 if (data_[i] != other.data_[i]) return false;
41 } 41 }
42 if (i < data_length_) { 42 if (i < data_length_) {
43 // Don't compare bits beyond length_. 43 // Don't compare bits beyond length_.
44 uword mask = 44 const intptr_t shift_size = (kBitsPerWord - length_) & (kBitsPerWord - 1);
45 static_cast<uword>(-1) >> (kBitsPerWord - (length_ % kBitsPerWord)); 45 const uword mask = static_cast<uword>(-1) >> shift_size;
46 if ((data_[i] & mask) != (other.data_[i] & mask)) return false; 46 if ((data_[i] & mask) != (other.data_[i] & mask)) return false;
47 } 47 }
48 return true; 48 return true;
49 } 49 }
50 50
51 51
52 bool BitVector::AddAll(const BitVector* from) { 52 bool BitVector::AddAll(const BitVector* from) {
53 ASSERT(data_length_ == from->data_length_); 53 ASSERT(data_length_ == from->data_length_);
54 bool changed = false; 54 bool changed = false;
55 for (intptr_t i = 0; i < data_length_; i++) { 55 for (intptr_t i = 0; i < data_length_; i++) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 void BitVector::Print() const { 103 void BitVector::Print() const {
104 OS::Print("["); 104 OS::Print("[");
105 for (intptr_t i = 0; i < length_; i++) { 105 for (intptr_t i = 0; i < length_; i++) {
106 OS::Print(Contains(i) ? "1" : "0"); 106 OS::Print(Contains(i) ? "1" : "0");
107 } 107 }
108 OS::Print("]"); 108 OS::Print("]");
109 } 109 }
110 110
111 } // namespace dart 111 } // namespace dart
OLDNEW
« 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