Skip to content

Commit 9aac51d

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

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
@@ -285,13 +285,13 @@ std::string expr2ct::convert_rec(
285285
if(width==config.ansi_c.int_width)
286286
{
287287
if(is_signed)
288-
sign_str="";
288+
sign_str.clear();
289289
return q+sign_str+"int"+d;
290290
}
291291
else if(width==config.ansi_c.long_int_width)
292292
{
293293
if(is_signed)
294-
sign_str="";
294+
sign_str.clear();
295295
return q+sign_str+"long int"+d;
296296
}
297297
else if(width==config.ansi_c.char_width)
@@ -302,19 +302,19 @@ std::string expr2ct::convert_rec(
302302
else if(width==config.ansi_c.short_int_width)
303303
{
304304
if(is_signed)
305-
sign_str="";
305+
sign_str.clear();
306306
return q+sign_str+"short int"+d;
307307
}
308308
else if(width==config.ansi_c.long_long_int_width)
309309
{
310310
if(is_signed)
311-
sign_str="";
311+
sign_str.clear();
312312
return q+sign_str+"long long int"+d;
313313
}
314314
else if(width==128)
315315
{
316316
if(is_signed)
317-
sign_str="";
317+
sign_str.clear();
318318
return q + sign_str + "__int128" + d;
319319
}
320320
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
@@ -129,7 +129,7 @@ int armcc_modet::doit()
129129
}
130130
else
131131
{
132-
compiler.output_file_object="";
132+
compiler.output_file_object.clear();
133133
compiler.output_file_executable="a.out";
134134
}
135135

src/goto-cc/cw_mode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ int cw_modet::doit()
9494
}
9595
else
9696
{
97-
compiler.output_file_object="";
97+
compiler.output_file_object.clear();
9898
compiler.output_file_executable="a.out";
9999
}
100100

src/goto-cc/gcc_mode.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ int gcc_modet::doit()
659659
}
660660
else
661661
{
662-
compiler.output_file_object="";
662+
compiler.output_file_object.clear();
663663
compiler.output_file_executable="a.out";
664664
}
665665

@@ -721,14 +721,14 @@ int gcc_modet::doit()
721721
{
722722
language=arg_it->arg;
723723
if(language=="none")
724-
language="";
724+
language.clear();
725725
}
726726
}
727727
else if(has_prefix(arg_it->arg, "-x"))
728728
{
729729
language=std::string(arg_it->arg, 2, std::string::npos);
730730
if(language=="none")
731-
language="";
731+
language.clear();
732732
}
733733
}
734734
}

src/goto-cc/ld_mode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int ld_modet::doit()
123123
}
124124
else
125125
{
126-
compiler.output_file_object = "";
126+
compiler.output_file_object.clear();
127127
compiler.output_file_executable = "a.out";
128128
}
129129

src/goto-cc/ms_cl_cmdline.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ void ms_cl_cmdlinet::process_cl_option(const std::string &s)
434434
if(s.size()==2)
435435
{
436436
option.islong=false;
437-
option.optstring="";
437+
option.optstring.clear();
438438
option.optchar=s[1];
439439
optnr=getoptnr(option.optchar);
440440
}
@@ -470,7 +470,7 @@ void ms_cl_cmdlinet::process_cl_option(const std::string &s)
470470
if(ms_cl_prefix.size()==1)
471471
{
472472
option.islong=false;
473-
option.optstring="";
473+
option.optstring.clear();
474474
option.optchar=ms_cl_prefix[0];
475475
optnr=getoptnr(option.optchar);
476476
}

src/goto-instrument/dump_c.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ void dump_ct::convert_compound(
452452
if(comp_type.id()==ID_c_bit_field &&
453453
to_c_bit_field_type(comp_type).get_width()==0)
454454
{
455-
comp_name="";
455+
comp_name.clear();
456456
s=type_to_string(comp_type);
457457
}
458458

@@ -502,7 +502,7 @@ void dump_ct::convert_compound(
502502
typedef_map.insert({typedef_str, typedef_infot(typedef_str)});
503503
PRECONDITION(!td_map_entry.second);
504504
if(!td_map_entry.first->second.early)
505-
td_map_entry.first->second.type_decl_str="";
505+
td_map_entry.first->second.type_decl_str.clear();
506506
os << "typedef ";
507507
}
508508

src/pointer-analysis/value_set.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ void value_sett::output(
107107
if(has_prefix(id2string(e.identifier), "value_set::dynamic_object"))
108108
{
109109
display_name=id2string(e.identifier)+e.suffix;
110-
identifier="";
110+
identifier.clear();
111111
}
112112
else if(e.identifier=="value_set::return_value")
113113
{
114114
display_name="RETURN_VALUE"+e.suffix;
115-
identifier="";
115+
identifier.clear();
116116
}
117117
else
118118
{

src/pointer-analysis/value_set_fi.cpp

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

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)