mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Use a cache for log_id() memory management
This commit is contained in:
parent
73f5ffcce8
commit
003336c58d
|
@ -44,6 +44,7 @@ bool log_cmd_error_throw = false;
|
||||||
int log_verbose_level;
|
int log_verbose_level;
|
||||||
|
|
||||||
std::vector<int> header_count;
|
std::vector<int> header_count;
|
||||||
|
std::set<RTLIL::IdString> log_id_cache;
|
||||||
std::list<std::string> string_buf;
|
std::list<std::string> string_buf;
|
||||||
int string_buf_size = 0;
|
int string_buf_size = 0;
|
||||||
|
|
||||||
|
@ -214,6 +215,7 @@ void log_push()
|
||||||
void log_pop()
|
void log_pop()
|
||||||
{
|
{
|
||||||
header_count.pop_back();
|
header_count.pop_back();
|
||||||
|
log_id_cache.clear();
|
||||||
string_buf.clear();
|
string_buf.clear();
|
||||||
string_buf_size = 0;
|
string_buf_size = 0;
|
||||||
log_flush();
|
log_flush();
|
||||||
|
@ -223,6 +225,7 @@ void log_reset_stack()
|
||||||
{
|
{
|
||||||
while (header_count.size() > 1)
|
while (header_count.size() > 1)
|
||||||
header_count.pop_back();
|
header_count.pop_back();
|
||||||
|
log_id_cache.clear();
|
||||||
string_buf.clear();
|
string_buf.clear();
|
||||||
string_buf_size = 0;
|
string_buf_size = 0;
|
||||||
log_flush();
|
log_flush();
|
||||||
|
@ -257,8 +260,8 @@ const char *log_signal(const RTLIL::SigSpec &sig, bool autoint)
|
||||||
|
|
||||||
const char *log_id(RTLIL::IdString str)
|
const char *log_id(RTLIL::IdString str)
|
||||||
{
|
{
|
||||||
|
log_id_cache.insert(str);
|
||||||
const char *p = str.c_str();
|
const char *p = str.c_str();
|
||||||
log_assert(RTLIL::IdString::global_refcount_storage_[str.index_] > 1);
|
|
||||||
if (p[0] == '\\' && p[1] != '$' && p[1] != 0)
|
if (p[0] == '\\' && p[1] != '$' && p[1] != 0)
|
||||||
return p+1;
|
return p+1;
|
||||||
return p;
|
return p;
|
||||||
|
|
Loading…
Reference in a new issue