This commit is contained in:
blueloveTH 2023-02-23 08:34:45 +08:00
parent ee46388841
commit 8fd38d0c81
3 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
g++ -o pocketpy src/main.cpp --std=c++17 -pg -O2 -fno-rtti
./pocketpy benchmarks/fib.py
./pocketpy benchmarks/primes.py
gprof pocketpy gmon.out > gprof.txt

View File

@ -66,7 +66,7 @@ struct CodeObject {
std::map<StrName, int> labels;
uint32_t perfect_locals_capacity = 2;
uint32_t perfect_hash_seed = 0xffffffff;
uint32_t perfect_hash_seed = -1;
void optimize(VM* vm);

View File

@ -20,7 +20,7 @@ namespace pkpy{
}
uint32_t find_perfect_hash_seed(uint32_t capacity, const std::vector<StrName>& keys){
if(keys.empty()) return 0xffffffff;
if(keys.empty()) return -1;
std::set<uint32_t> indices;
std::vector<std::pair<uint32_t, float>> scores;
for(int i=0; i<kHashSeeds.size(); i++){
@ -49,7 +49,7 @@ namespace pkpy{
uint32_t _hash_seed;
NameDictNode* _a;
NameDict(uint32_t capacity=2, float load_factor=0.67, uint32_t hash_seed=0xffffffff):
NameDict(uint32_t capacity=2, float load_factor=0.67, uint32_t hash_seed=-1):
_capacity(capacity), _size(0), _load_factor(load_factor),
_hash_seed(hash_seed), _a(new NameDictNode[capacity]) {}