summaryrefslogtreecommitdiff
path: root/Source/WTF/wtf/FastBitVector.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WTF/wtf/FastBitVector.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WTF/wtf/FastBitVector.cpp')
-rw-r--r--Source/WTF/wtf/FastBitVector.cpp48
1 files changed, 42 insertions, 6 deletions
diff --git a/Source/WTF/wtf/FastBitVector.cpp b/Source/WTF/wtf/FastBitVector.cpp
index 3abccea73..eed316975 100644
--- a/Source/WTF/wtf/FastBitVector.cpp
+++ b/Source/WTF/wtf/FastBitVector.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,14 +26,50 @@
#include "config.h"
#include "FastBitVector.h"
-#include "PrintStream.h"
-
namespace WTF {
-void FastBitVector::dump(PrintStream& out) const
+void FastBitVectorWordOwner::setEqualsSlow(const FastBitVectorWordOwner& other)
+{
+ uint32_t* newArray = static_cast<uint32_t*>(
+ fastCalloc(other.arrayLength(), sizeof(uint32_t)));
+ memcpy(newArray, other.m_words, other.arrayLength() * sizeof(uint32_t));
+ if (m_words)
+ fastFree(m_words);
+ m_words = newArray;
+ m_numBits = other.m_numBits;
+}
+
+void FastBitVectorWordOwner::resizeSlow(size_t numBits)
+{
+ size_t newLength = fastBitVectorArrayLength(numBits);
+
+ // Use fastCalloc instead of fastRealloc because we expect the common
+ // use case for this method to be initializing the size of the bitvector.
+
+ uint32_t* newArray = static_cast<uint32_t*>(fastCalloc(newLength, sizeof(uint32_t)));
+ memcpy(newArray, m_words, arrayLength() * sizeof(uint32_t));
+ if (m_words)
+ fastFree(m_words);
+ m_words = newArray;
+}
+
+void FastBitVector::clearRange(size_t begin, size_t end)
{
- for (unsigned i = 0; i < m_numBits; ++i)
- out.print(get(i) ? "1" : "-");
+ if (end - begin < 32) {
+ for (size_t i = begin; i < end; ++i)
+ at(i) = false;
+ return;
+ }
+
+ size_t endBeginSlop = (begin + 31) & ~31;
+ size_t beginEndSlop = end & ~31;
+
+ for (size_t i = begin; i < endBeginSlop; ++i)
+ at(i) = false;
+ for (size_t i = beginEndSlop; i < end; ++i)
+ at(i) = false;
+ for (size_t i = endBeginSlop / 32; i < beginEndSlop / 32; ++i)
+ m_words.word(i) = 0;
}
} // namespace WTF