blueloveTH 2 лет назад
Родитель
Сommit
7f3d89b264
2 измененных файлов с 2 добавлено и 2 удалено
  1. 1 1
      include/pocketpy/namedict.h
  2. 1 1
      src/vm.cpp

+ 1 - 1
include/pocketpy/namedict.h

@@ -32,7 +32,7 @@ struct NameDictImpl {
 #define HASH_PROBE(key, ok, i)          \
 ok = false;                             \
 i = _hash(key, _mask, _hash_seed);      \
-while(true) {       \
+for(int _j=0; _j<_capacity; _j++) {       \
     if(!_items[i].first.empty()){       \
         if(_items[i].first == (key)) { ok = true; break; }  \
     }else{                                                  \

+ 1 - 1
src/vm.cpp

@@ -1036,7 +1036,7 @@ void Dict::_probe(PyObject *key, bool &ok, int &i) const{
     i64 hash = vm->py_hash(key);
     i = hash & _mask;
     // std::cout << CAST(Str, vm->py_repr(key)) << " " << hash << " " << i << std::endl;
-    while(true) {
+    for(int j=0; j<_capacity; j++) {
         if(_items[i].first != nullptr){
             if(vm->py_equals(_items[i].first, key)) { ok = true; break; }
         }else{