Skip to content

Commit 1f5aebb

Browse files
committed
Support multi-word early exits
1 parent 883454e commit 1f5aebb

File tree

35 files changed

+495
-108
lines changed

35 files changed

+495
-108
lines changed

Docs/Optimizations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Input `cow pig cat`
4949
It will produce: `if (value.Length != 3) return false;`
5050

5151
### Length bitmap early exit
52-
FastData can also sometimes produce a bitmap of value lengths. It basically map lengths into a 64bit integer and check if the corresponding bit is set.
52+
FastData can also sometimes produce a bitmap of value lengths. It basically map lengths into a 64bit integer and check if the corresponding bit is set. For larger ranges, it can emit a multi-word bitset.
5353
Input: `stable softice sophisticated santa`
5454

5555
It generates this early exit: `if ((4208UL & (1UL << (value.Length - 1))) == 0) return false;`

Src/FastData.Generator.CPlusPlus.Tests/Features/ObjectSupportTest-ArrayStructure_Int32_3_complex.verified.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ public:
3737
[[nodiscard]]
3838
static bool try_lookup(const int32_t key, const Person*& value) noexcept {
3939
if (key < 1 || key > 3)
40-
return false;
40+
{
41+
value = nullptr;
42+
return false;
43+
}
4144

4245
for (size_t i = 0; i < 3; i++) {
4346
if (keys[i] == key) {

Src/FastData.Generator.CPlusPlus.Tests/Features/ObjectSupportTest-ArrayStructure_Int32_3_simple.verified.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ public:
3030
[[nodiscard]]
3131
static bool try_lookup(const int32_t key, const int32_t*& value) noexcept {
3232
if (key < 1 || key > 3)
33-
return false;
33+
{
34+
value = nullptr;
35+
return false;
36+
}
3437

3538
for (size_t i = 0; i < 3; i++) {
3639
if (keys[i] == key) {

Src/FastData.Generator.CPlusPlus.Tests/Features/ObjectSupportTest-BinarySearchStructure_Int32_3_complex.verified.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ public:
4747
[[nodiscard]]
4848
static bool try_lookup(const int32_t key, const Person*& value) noexcept {
4949
if (key < 1 || key > 3)
50-
return false;
50+
{
51+
value = nullptr;
52+
return false;
53+
}
5154

5255
int32_t lo = 0;
5356
int32_t hi = 2;

Src/FastData.Generator.CPlusPlus.Tests/Features/ObjectSupportTest-BinarySearchStructure_Int32_3_simple.verified.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ public:
4040
[[nodiscard]]
4141
static bool try_lookup(const int32_t key, const int32_t*& value) noexcept {
4242
if (key < 1 || key > 3)
43-
return false;
43+
{
44+
value = nullptr;
45+
return false;
46+
}
4447

4548
int32_t lo = 0;
4649
int32_t hi = 2;

Src/FastData.Generator.CPlusPlus.Tests/Features/ObjectSupportTest-BitSetStructure_Int32_3_complex.verified.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ public:
3333
[[nodiscard]]
3434
static bool try_lookup(const int32_t key, const Person*& value) noexcept {
3535
if (key < 1 || key > 3)
36-
return false;
36+
{
37+
value = nullptr;
38+
return false;
39+
}
3740

3841
const uint64_t offset = static_cast<uint64_t>(key - min_key);
3942
const size_t word = static_cast<size_t>(offset >> 6);

Src/FastData.Generator.CPlusPlus.Tests/Features/ObjectSupportTest-HashTablePerfectStructure_Int32_3_complex.verified.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ public:
4646
[[nodiscard]]
4747
static bool try_lookup(const int32_t key, const Person*& value) noexcept {
4848
if (key < 1 || key > 3)
49-
return false;
49+
{
50+
value = nullptr;
51+
return false;
52+
}
5053

5154
const uint64_t hash = get_hash(key);
5255
const size_t index = hash % 3;

Src/FastData.Generator.CPlusPlus.Tests/Features/ObjectSupportTest-HashTablePerfectStructure_Int32_3_simple.verified.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ public:
3939
[[nodiscard]]
4040
static bool try_lookup(const int32_t key, const int32_t*& value) noexcept {
4141
if (key < 1 || key > 3)
42-
return false;
42+
{
43+
value = nullptr;
44+
return false;
45+
}
4346

4447
const uint64_t hash = get_hash(key);
4548
const size_t index = hash % 3;

Src/FastData.Generator.CPlusPlus.Tests/Features/ObjectSupportTest-HashTableStructure_Int32_3_complex.verified.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ public:
6060
[[nodiscard]]
6161
static bool try_lookup(const int32_t key, const Person*& value) noexcept {
6262
if (key < 1 || key > 3)
63-
return false;
63+
{
64+
value = nullptr;
65+
return false;
66+
}
6467

6568
const uint64_t hash = get_hash(key);
6669
const size_t index = hash % 3;

Src/FastData.Generator.CPlusPlus.Tests/Features/ObjectSupportTest-HashTableStructure_Int32_3_simple.verified.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ public:
5353
[[nodiscard]]
5454
static bool try_lookup(const int32_t key, const int32_t*& value) noexcept {
5555
if (key < 1 || key > 3)
56-
return false;
56+
{
57+
value = nullptr;
58+
return false;
59+
}
5760

5861
const uint64_t hash = get_hash(key);
5962
const size_t index = hash % 3;

0 commit comments

Comments
 (0)