Skip to content

Commit e7a6f6c

Browse files
committed
Use s.clear() instead of s=""
This avoids string table lookups.
1 parent a7fcea1 commit e7a6f6c

17 files changed

+30
-30
lines changed

jbmc/unit/pointer-analysis/custom_value_set_analysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ SCENARIO("test_value_set_analysis",
171171
GIVEN("Normal and custom value-set analysis of CustomVSATest::test")
172172
{
173173
config.set_arch("none");
174-
config.main = "";
174+
config.main.clear();
175175

176176
// This classpath is the default, but the config object
177177
// is global and previous unit tests may have altered it

src/ansi-c/expr2c.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,13 @@ std::string expr2ct::convert_rec(
281281
if(width==config.ansi_c.int_width)
282282
{
283283
if(is_signed)
284-
sign_str="";
284+
sign_str.clear();
285285
return q+sign_str+"int"+d;
286286
}
287287
else if(width==config.ansi_c.long_int_width)
288288
{
289289
if(is_signed)
290-
sign_str="";
290+
sign_str.clear();
291291
return q+sign_str+"long int"+d;
292292
}
293293
else if(width==config.ansi_c.char_width)
@@ -298,19 +298,19 @@ std::string expr2ct::convert_rec(
298298
else if(width==config.ansi_c.short_int_width)
299299
{
300300
if(is_signed)
301-
sign_str="";
301+
sign_str.clear();
302302
return q+sign_str+"short int"+d;
303303
}
304304
else if(width==config.ansi_c.long_long_int_width)
305305
{
306306
if(is_signed)
307-
sign_str="";
307+
sign_str.clear();
308308
return q+sign_str+"long long int"+d;
309309
}
310310
else if(width==128)
311311
{
312312
if(is_signed)
313-
sign_str="";
313+
sign_str.clear();
314314
return q + sign_str + "__int128" + d;
315315
}
316316
else

src/cpp/cpp_name.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void cpp_namet::convert(
6666
identifier+=name_component;
6767

6868
if(id=="::")
69-
base_name="";
69+
base_name.clear();
7070
else
7171
base_name+=name_component;
7272
}

src/cpp/cpp_token.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class cpp_tokent
2929
{
3030
kind=0;
3131
data.clear();
32-
text="";
32+
text.clear();
3333
line_no=0;
34-
filename="";
34+
filename.clear();
3535
}
3636

3737
void swap(cpp_tokent &token)

src/cpp/cpp_typecheck_resolve.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ void cpp_typecheck_resolvet::show_identifiers(
12771277
else if(id_expr.id() == ID_pod_constructor)
12781278
{
12791279
out << "constructor ";
1280-
id="";
1280+
id.clear();
12811281
}
12821282
else if(id_expr.id()==ID_template_function_instance)
12831283
{

src/goto-cc/armcc_mode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ int armcc_modet::doit()
126126
}
127127
else
128128
{
129-
compiler.output_file_object="";
129+
compiler.output_file_object.clear();
130130
compiler.output_file_executable="a.out";
131131
}
132132

src/goto-cc/cw_mode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int cw_modet::doit()
9191
}
9292
else
9393
{
94-
compiler.output_file_object="";
94+
compiler.output_file_object.clear();
9595
compiler.output_file_executable="a.out";
9696
}
9797

src/goto-cc/gcc_mode.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ int gcc_modet::doit()
656656
}
657657
else
658658
{
659-
compiler.output_file_object="";
659+
compiler.output_file_object.clear();
660660
compiler.output_file_executable="a.out";
661661
}
662662

@@ -718,14 +718,14 @@ int gcc_modet::doit()
718718
{
719719
language=arg_it->arg;
720720
if(language=="none")
721-
language="";
721+
language.clear();
722722
}
723723
}
724724
else if(has_prefix(arg_it->arg, "-x"))
725725
{
726726
language=std::string(arg_it->arg, 2, std::string::npos);
727727
if(language=="none")
728-
language="";
728+
language.clear();
729729
}
730730
}
731731
}

src/goto-cc/ld_mode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ int ld_modet::doit()
120120
}
121121
else
122122
{
123-
compiler.output_file_object = "";
123+
compiler.output_file_object.clear();
124124
compiler.output_file_executable = "a.out";
125125
}
126126

src/goto-cc/ms_cl_cmdline.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ void ms_cl_cmdlinet::process_cl_option(const std::string &s)
431431
if(s.size()==2)
432432
{
433433
option.islong=false;
434-
option.optstring="";
434+
option.optstring.clear();
435435
option.optchar=s[1];
436436
optnr=getoptnr(option.optchar);
437437
}
@@ -467,7 +467,7 @@ void ms_cl_cmdlinet::process_cl_option(const std::string &s)
467467
if(ms_cl_prefix.size()==1)
468468
{
469469
option.islong=false;
470-
option.optstring="";
470+
option.optstring.clear();
471471
option.optchar=ms_cl_prefix[0];
472472
optnr=getoptnr(option.optchar);
473473
}

src/goto-instrument/dump_c.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ void dump_ct::convert_compound(
447447
if(comp_type.id()==ID_c_bit_field &&
448448
to_c_bit_field_type(comp_type).get_width()==0)
449449
{
450-
comp_name="";
450+
comp_name.clear();
451451
s=type_to_string(comp_type);
452452
}
453453

@@ -497,7 +497,7 @@ void dump_ct::convert_compound(
497497
typedef_map.insert({typedef_str, typedef_infot(typedef_str)});
498498
PRECONDITION(!td_map_entry.second);
499499
if(!td_map_entry.first->second.early)
500-
td_map_entry.first->second.type_decl_str="";
500+
td_map_entry.first->second.type_decl_str.clear();
501501
os << "typedef ";
502502
}
503503

src/pointer-analysis/value_set.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ void value_sett::output(
110110
if(has_prefix(id2string(e.identifier), "value_set::dynamic_object"))
111111
{
112112
display_name=id2string(e.identifier)+e.suffix;
113-
identifier="";
113+
identifier.clear();
114114
}
115115
else if(e.identifier=="value_set::return_value")
116116
{
117117
display_name="RETURN_VALUE"+e.suffix;
118-
identifier="";
118+
identifier.clear();
119119
}
120120
else
121121
{

src/pointer-analysis/value_set_fi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void value_set_fit::output(
5858
if(has_prefix(id2string(e.identifier), "value_set::dynamic_object"))
5959
{
6060
display_name=id2string(e.identifier)+e.suffix;
61-
identifier="";
61+
identifier.clear();
6262
}
6363
else
6464
{

src/util/cmdline.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ bool cmdlinet::parse(int argc, const char **argv, const char *optstring)
169169
option.islong=true;
170170
option.optchar=0;
171171
option.isset=false;
172-
option.optstring="";
172+
option.optstring.clear();
173173

174174
for(optstring++; optstring[0]!=')' && optstring[0]!=0; optstring++)
175175
option.optstring+=optstring[0];
@@ -181,7 +181,7 @@ bool cmdlinet::parse(int argc, const char **argv, const char *optstring)
181181
{
182182
option.islong=false;
183183
option.optchar=optstring[0];
184-
option.optstring="";
184+
option.optstring.clear();
185185
option.isset=false;
186186

187187
optstring++;

src/util/identifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ void identifiert::parse(const std::string &s)
4343
}
4444

4545
components.push_back(component);
46-
component="";
46+
component.clear();
4747
}
4848
}

src/util/lispexpr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ bool lispexprt::parse(
6262
std::string::size_type &ptr)
6363
{
6464
clear();
65-
value="";
65+
value.clear();
6666

6767
if(ptr==std::string::npos || ptr>=s.size())
6868
return true;
@@ -156,7 +156,7 @@ int test_lispexpr()
156156

157157
while(true)
158158
{
159-
line="";
159+
line.clear();
160160

161161
while(true)
162162
{

src/util/lispirep.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void lisp2irep(const lispexprt &src, irept &dest)
4343
void irep2lisp(const irept &src, lispexprt &dest)
4444
{
4545
dest.clear();
46-
dest.value="";
46+
dest.value.clear();
4747
dest.type=lispexprt::List;
4848

4949
#ifdef NAMED_SUB_IS_FORWARD_LIST
@@ -65,7 +65,7 @@ void irep2lisp(const irept &src, lispexprt &dest)
6565
{
6666
lispexprt name;
6767
name.type=lispexprt::String;
68-
name.value="";
68+
name.value.clear();
6969
dest.push_back(name);
7070

7171
lispexprt sub;

0 commit comments

Comments
 (0)