From f2ea8e28ecbd2205d6a6aed5b2e31cd6248fe024 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 7 Jan 2024 01:37:40 +0800 Subject: [PATCH] ... --- include/pocketpy/expr.h | 2 +- src/expr.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/pocketpy/expr.h b/include/pocketpy/expr.h index 7211c0c8..4c3480a3 100644 --- a/include/pocketpy/expr.h +++ b/include/pocketpy/expr.h @@ -56,7 +56,7 @@ struct CodeEmitContext{ int for_loop_depth = 0; std::map _co_consts_nonstring_dedup_map; - std::map _co_consts_string_dedup_map; + std::map> _co_consts_string_dedup_map; int get_loop() const; CodeBlock* enter_block(CodeBlockType type); diff --git a/src/expr.cpp b/src/expr.cpp index 358c8f97..f5ba2a9b 100644 --- a/src/expr.cpp +++ b/src/expr.cpp @@ -89,14 +89,14 @@ namespace pkpy{ int CodeEmitContext::add_const(PyObject* v){ if(is_non_tagged_type(v, vm->tp_str)){ // string deduplication - std::string key = PK_OBJ_GET(Str, v).str(); + std::string_view key = PK_OBJ_GET(Str, v).sv(); auto it = _co_consts_string_dedup_map.find(key); if(it != _co_consts_string_dedup_map.end()){ return it->second; }else{ co->consts.push_back(v); int index = co->consts.size() - 1; - _co_consts_string_dedup_map[key] = index; + _co_consts_string_dedup_map[std::string(key)] = index; return index; } }else{