This commit is contained in:
blueloveTH 2023-07-03 23:37:19 +08:00
parent f138ef2db5
commit d7cf7e070b
2 changed files with 3 additions and 3 deletions

View File

@ -23,7 +23,7 @@ struct Str{
char* data;
char _inlined[16];
const char* _cached_c_str = nullptr;
mutable const char* _cached_c_str = nullptr;
bool is_inlined() const { return data == _inlined; }
@ -124,7 +124,7 @@ struct Str{
Str substr(int start, int len) const;
Str substr(int start) const;
char* c_str_dup() const;
const char* c_str();
const char* c_str() const;
std::string_view sv() const;
std::string str() const;
Str lstrip() const;

View File

@ -103,7 +103,7 @@ namespace pkpy {
return p;
}
const char* Str::c_str(){
const char* Str::c_str() const{
if(_cached_c_str == nullptr){
_cached_c_str = c_str_dup();
}