mirror of
https://github.com/pocketpy/pocketpy
synced 2025-12-07 10:40:16 +00:00
up
This commit is contained in:
parent
49a52f000d
commit
b2b56316b2
@ -170,30 +170,6 @@ namespace pkpy{
|
|||||||
_size--;
|
_size--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_stats(){
|
|
||||||
std::map<StrName, uint32_t> stats;
|
|
||||||
for(uint32_t i=0; i<_capacity; i++){
|
|
||||||
if(_a[i].empty()) continue;
|
|
||||||
stats[_a[i].first] = 1;
|
|
||||||
}
|
|
||||||
for(auto [key, _]: stats){
|
|
||||||
bool ok = false; uint32_t i;
|
|
||||||
i = _hash(key, _capacity, _hash_seed);
|
|
||||||
while(!_a[i].empty()) {
|
|
||||||
if(_a[i].first == (key)) { ok = true; break; }
|
|
||||||
i = (i + 1) % _capacity;
|
|
||||||
stats[key]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(uint32_t i=0; i<_capacity; i++){
|
|
||||||
if(_a[i].empty()) {
|
|
||||||
std::cout << i << ": <NULL>" << std::endl;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::cout << i << ": <" << _a[i].first.str() << ", " << stats[_a[i].first] << '>' << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<NameDictNode> items() const {
|
std::vector<NameDictNode> items() const {
|
||||||
std::vector<NameDictNode> v;
|
std::vector<NameDictNode> v;
|
||||||
for(uint32_t i=0; i<_capacity; i++){
|
for(uint32_t i=0; i<_capacity; i++){
|
||||||
@ -212,6 +188,30 @@ namespace pkpy{
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
#undef HASH_PROBE
|
#undef HASH_PROBE
|
||||||
|
|
||||||
|
// void print_stats(){
|
||||||
|
// std::map<StrName, uint32_t> stats;
|
||||||
|
// for(uint32_t i=0; i<_capacity; i++){
|
||||||
|
// if(_a[i].empty()) continue;
|
||||||
|
// stats[_a[i].first] = 1;
|
||||||
|
// }
|
||||||
|
// for(auto [key, _]: stats){
|
||||||
|
// bool ok = false; uint32_t i;
|
||||||
|
// i = _hash(key, _capacity, _hash_seed);
|
||||||
|
// while(!_a[i].empty()) {
|
||||||
|
// if(_a[i].first == (key)) { ok = true; break; }
|
||||||
|
// i = (i + 1) % _capacity;
|
||||||
|
// stats[key]++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// for(uint32_t i=0; i<_capacity; i++){
|
||||||
|
// if(_a[i].empty()) {
|
||||||
|
// std::cout << i << ": <NULL>" << std::endl;
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// std::cout << i << ": <" << _a[i].first.str() << ", " << stats[_a[i].first] << '>' << std::endl;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pkpy
|
} // namespace pkpy
|
||||||
@ -99,9 +99,9 @@ struct Py_ : PyObject {
|
|||||||
|
|
||||||
inline void _init() noexcept {
|
inline void _init() noexcept {
|
||||||
if constexpr (std::is_same_v<T, Type> || std::is_same_v<T, DummyModule>) {
|
if constexpr (std::is_same_v<T, Type> || std::is_same_v<T, DummyModule>) {
|
||||||
_attr = new pkpy::NameDict(4, kTypeAttrLoadFactor);
|
_attr = new pkpy::NameDict(17, kTypeAttrLoadFactor);
|
||||||
}else if constexpr(std::is_same_v<T, DummyInstance>){
|
}else if constexpr(std::is_same_v<T, DummyInstance>){
|
||||||
_attr = new pkpy::NameDict(4, kInstAttrLoadFactor);
|
_attr = new pkpy::NameDict(5, kInstAttrLoadFactor);
|
||||||
}else{
|
}else{
|
||||||
_attr = nullptr;
|
_attr = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user