File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -108,22 +108,30 @@ IdString initial_id;
108108
109109void reset_auto_counter_id (RTLIL::IdString id, bool may_rename)
110110{
111- const char *str = id.c_str ();
111+ auto it = id.begin ();
112+ auto it_end = id.end ();
113+ if (it == it_end)
114+ return ;
112115
113- if (*str == ' $' && may_rename && !norename)
116+ if (*it == ' $' && may_rename && !norename)
114117 auto_name_map[id] = auto_name_counter++;
115118
116- if (str[ 0 ] != ' \\ ' || str[ 1 ] != ' _' || str[ 2 ] == 0 )
119+ if (*it != ' \\ ' || *it != ' _' || (it + 1 ) == it_end )
117120 return ;
118121
119- for (int i = 2 ; str[i] != 0 ; i++) {
120- if (str[i] == ' _' && str[i+1 ] == 0 )
122+ it += 2 ;
123+ auto start = it;
124+ while (it != it_end) {
125+ char ch = *it;
126+ if (ch == ' _' && (it + 1 ) == it_end)
121127 continue ;
122- if (str[i] < ' 0' || str[i] > ' 9' )
128+ if (ch < ' 0' || ch > ' 9' )
123129 return ;
124130 }
125131
126- int num = atoi (str+2 );
132+ std::string s;
133+ std::copy (start, it_end, std::back_inserter (s));
134+ int num = atoi (s.c_str ());
127135 if (num >= auto_name_offset)
128136 auto_name_offset = num + 1 ;
129137}
You can’t perform that action at this time.
0 commit comments