This commit is contained in:
blueloveTH 2023-02-24 23:09:38 +08:00
parent e5da206ded
commit 298739bfef
2 changed files with 6 additions and 6 deletions

View File

@ -117,7 +117,7 @@ static_assert(std::numeric_limits<double>::is_iec559);
template<typename T, int __Bucket, int __BucketSize=32> template<typename T, int __Bucket, int __BucketSize=32>
struct SmallArrayPool { struct SmallArrayPool {
std::deque<T*> buckets[__Bucket+1]; std::vector<T*> buckets[__Bucket+1];
T* alloc(int n){ T* alloc(int n){
if(n == 0) return nullptr; if(n == 0) return nullptr;

View File

@ -133,9 +133,9 @@ bool is_unicode_Lo_char(uint32_t c) {
struct StrName { struct StrName {
uint32_t index; uint16_t index;
StrName(): index(0) {} StrName(): index(0) {}
StrName(int index): index(index) {} StrName(uint16_t index): index(index) {}
StrName(const char* s): index(get(s).index) {} StrName(const char* s): index(get(s).index) {}
StrName(const Str& s): index(get(s).index) {} StrName(const Str& s): index(get(s).index) {}
inline const Str& str() const { return _r_interned[index-1]; } inline const Str& str() const { return _r_interned[index-1]; }
@ -157,7 +157,7 @@ struct StrName {
return this->index > other.index; return this->index > other.index;
} }
static std::map<Str, uint32_t, std::less<>> _interned; static std::map<Str, uint16_t, std::less<>> _interned;
static std::vector<Str> _r_interned; static std::vector<Str> _r_interned;
inline static StrName get(const Str& s){ inline static StrName get(const Str& s){
@ -167,14 +167,14 @@ struct StrName {
static StrName get(const char* s){ static StrName get(const char* s){
auto it = _interned.find(s); auto it = _interned.find(s);
if(it != _interned.end()) return StrName(it->second); if(it != _interned.end()) return StrName(it->second);
uint32_t index = _r_interned.size() + 1; uint16_t index = (uint16_t)(_r_interned.size() + 1);
_interned[s] = index; _interned[s] = index;
_r_interned.push_back(s); _r_interned.push_back(s);
return StrName(index); return StrName(index);
} }
}; };
std::map<Str, uint32_t, std::less<>> StrName::_interned; std::map<Str, uint16_t, std::less<>> StrName::_interned;
std::vector<Str> StrName::_r_interned; std::vector<Str> StrName::_r_interned;
const StrName __class__ = StrName::get("__class__"); const StrName __class__ = StrName::get("__class__");