Store public selector offsets as int32
This commit is contained in:
1 parent
c8e49aead8
commit
24f28dd9c8
10 files changed
+247
-227
No files matched your search
@@ -61,15 +61,15 @@ inline OptKey randomOptKey(Bytes& b, std::size_t maxLen) {
|
||||
return OptKey{randomKey(b, maxLen)};
|
||||
}
|
||||
|
||||
inline Int randomOffset(Bytes& b) {
|
||||
inline std::int32_t randomOffset(Bytes& b) {
|
||||
// Bias towards the offsets that decide the interesting boundary cases, but
|
||||
// still allow the full [-256, 255] window.
|
||||
std::uint8_t pick = b.u8();
|
||||
if (pick < 192) {
|
||||
static const Int small[] = {-3, -2, -1, 0, 1, 2, 3, 4, 5};
|
||||
static const std::int32_t small[] = {-3, -2, -1, 0, 1, 2, 3, 4, 5};
|
||||
return small[pick % 9];
|
||||
}
|
||||
return static_cast<Int>(b.u16() % 512) - 256;
|
||||
return static_cast<std::int32_t>(b.u16() % 512) - 256;
|
||||
}
|
||||
|
||||
inline OptKey resolve(const std::vector<Key>& db, const Selector& s) {
|
||||
@@ -77,7 +77,7 @@ inline OptKey resolve(const std::vector<Key>& db, const Selector& s) {
|
||||
if (!s.key) {
|
||||
anchor = static_cast<Int>(db.size()) + s.offset - 1;
|
||||
} else if (s.key->empty()) {
|
||||
anchor = s.offset - 1;
|
||||
anchor = static_cast<Int>(s.offset) - 1;
|
||||
} else {
|
||||
std::size_t below = 0;
|
||||
for (const Key& k : db)
|
||||
@@ -110,8 +110,8 @@ struct Instance {
|
||||
// Owned selector keys; `read()` borrows them.
|
||||
OptKey beginKey;
|
||||
OptKey endKey;
|
||||
Int beginOffset = 0;
|
||||
Int endOffset = 0;
|
||||
std::int32_t beginOffset = 0;
|
||||
std::int32_t endOffset = 0;
|
||||
bool reverse = false;
|
||||
bool more = false;
|
||||
|
||||
|
||||
Reference in new issue
Block a user