Skip to content

Commit

Permalink
Merge pull request #11 from Oppen/perf/rc_tables
Browse files Browse the repository at this point in the history
perf: use `shared_ptr` for tables
  • Loading branch information
Lartu authored Sep 5, 2024
2 parents be628d3 + 87f1674 commit d501962
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions narivm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ class Value
bool has_str_rep;
string str_rep;
double num_rep;
map<string, Value> *table_rep; // TODO: this is probably a huge memory leak lol
shared_ptr<map<string, Value>> table_rep;
queue<string> *iterator_elements;

void reset_values()
Expand Down Expand Up @@ -430,7 +430,7 @@ class Value
void set_table_value()
{
reset_values();
this->table_rep = new map<string, Value>();
this->table_rep = std::make_shared<map<string, Value>>();
this->type = TABLE;
}

Expand Down Expand Up @@ -460,7 +460,7 @@ class Value

map<string, Value> *get_table()
{
return table_rep;
return table_rep.get();
}

queue<string> *get_iterator_queue()
Expand Down

0 comments on commit d501962

Please sign in to comment.