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

Unified Diff: src/data-flow.h

Issue 668259: Add copy constructor and assignment operator to the BitVector class. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-dataflow.cc » ('j') | test/cctest/test-dataflow.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/data-flow.h
===================================================================
--- src/data-flow.h (revision 4056)
+++ src/data-flow.h (working copy)
@@ -36,18 +36,29 @@
namespace v8 {
namespace internal {
-class BitVector {
+class BitVector BASE_EMBEDDED {
public:
- explicit BitVector(int length) : length_(length) {
+ explicit BitVector(int length)
+ : length_(length), bits_(Vector<uint32_t>::New(1 + length / 32)) {
ASSERT(length > 0);
- bits_ = Vector<uint32_t>::New(1 + length / 32);
for (int i = 0; i < bits_.length(); i++) {
bits_[i] = 0;
}
}
+ BitVector(const BitVector& other)
+ : length_(other.length()),
+ bits_(Vector<uint32_t>::New(1 + other.length() / 32)) {
+ CopyFrom(other);
+ }
+
~BitVector() { bits_.Dispose(); }
+ BitVector& operator=(const BitVector& rhs) {
+ if (this != &rhs) CopyFrom(rhs);
+ return *this;
+ }
+
void CopyFrom(const BitVector& other) {
ASSERT(other.length() == length());
for (int i = 0; i < bits_.length(); i++) {
@@ -85,13 +96,25 @@
}
}
+ void Clear() {
+ for (int i = 0; i < bits_.length(); i++) {
+ bits_[i] = 0;
+ }
+ }
+
+ bool IsEmpty() {
+ for (int i = 0; i < bits_.length(); i++) {
+ if (bits_[i] != 0) return false;
+ }
+ return true;
+ }
+
int length() const { return length_; }
private:
int length_;
Vector<uint32_t> bits_;
- DISALLOW_COPY_AND_ASSIGN(BitVector);
};
« no previous file with comments | « no previous file | test/cctest/test-dataflow.cc » ('j') | test/cctest/test-dataflow.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698