From d6723686961bebe97eac002bdb3e276a75256121 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 5 Jun 2015 12:54:36 +0200 Subject: Add a version of BitVector that uses QBitArray. Some C++ STL libraries are unable to ship a bug-free std::vector, and/or a bug-free specialization of std::find for std::vector. So, for those platforms there now is a slow version of BitVector, which relies on QBitArray, which we can fix if we find bugs. Change-Id: I5ddfb18cabe82049a7ede6083fe6ba142bca068b Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4ssa.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'src/qml/compiler/qv4ssa.cpp') diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index 5829e1c813..e61a602e64 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -81,6 +81,8 @@ static void showMeTheCode(IR::Function *function, const char *marker) } } +#if !defined(BROKEN_STD_VECTOR_BOOL_OR_BROKEN_STD_FIND) +// Sanity: class BitVector { std::vector bits; @@ -140,6 +142,58 @@ public: void clearBit(int idx) { bits[idx] = false; } }; +#else // Insanity: +class BitVector +{ + QBitArray bits; + +public: + BitVector(int size = 0, bool value = false) + : bits(size, value) + {} + + void reserve(int size) + { Q_UNUSED(size); } + + int size() const + { return bits.size(); } + + void resize(int newSize) + { bits.resize(newSize); } + + void assign(int newSize, bool value) + { + bits.resize(newSize); + bits.fill(value); + } + + int findNext(int start, bool value, bool wrapAround) const + { + for (int i = start, ei = size(); i < ei; ++i) { + if (at(i) == value) + return i; + } + + if (wrapAround) { + for (int i = 0, ei = start; i < ei; ++i) { + if (at(i) == value) + return i; + } + } + + return size(); + } + + bool at(int idx) const + { return bits.at(idx); } + + void setBit(int idx) + { bits[idx] = true; } + + void clearBit(int idx) + { bits[idx] = false; } +}; +#endif class ProcessedBlocks { -- cgit v1.2.3