[decompiler] performance improvements in extraction (#1309)

* small speedups to extractor

* faster extraction
This commit is contained in:
water111
2022-04-15 20:40:10 -04:00
committed by GitHub
parent 65de778b5c
commit 97dc0e14df
17 changed files with 183 additions and 70 deletions
+22
View File
@@ -15,6 +15,7 @@
#include "common/util/print_float.h"
#include "common/util/CopyOnWrite.h"
#include "common/util/SmallVector.h"
#include "common/util/crc32.h"
TEST(CommonUtil, CpuInfo) {
setup_cpu_info();
@@ -396,5 +397,26 @@ TEST(Assert, Death) {
EXPECT_DEATH(private_assert_failed("foo", "bar", 12, "aaa"), "");
}
uint32_t crc_reference(const u8* data, size_t size) {
u32 crc = 0xffffffff;
while (size--) {
crc ^= *data++;
for (int k = 0; k < 8; k++)
crc = crc & 1 ? (crc >> 1) ^ 0x82f63b78 : crc >> 1;
}
return ~crc;
}
TEST(CRC32, Reference) {
for (u32 so = 0; so < 7; so++) {
std::vector<u8> test_data;
for (u32 i = 0; i < 1024 + so; i++) {
test_data.push_back(i & 0xff);
}
EXPECT_EQ(crc_reference(test_data.data(), test_data.size()),
crc32(test_data.data(), test_data.size()));
}
}
} // namespace test
} // namespace cu