From d7cf7e070b17dde127b4bd3b39678c6cbbb59616 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 3 Jul 2023 23:37:19 +0800 Subject: [PATCH] ... --- include/pocketpy/str.h | 4 ++-- src/str.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/pocketpy/str.h b/include/pocketpy/str.h index 612b720b..4a4b4ded 100644 --- a/include/pocketpy/str.h +++ b/include/pocketpy/str.h @@ -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; diff --git a/src/str.cpp b/src/str.cpp index d98bb24d..35cb1f2b 100644 --- a/src/str.cpp +++ b/src/str.cpp @@ -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(); }