Skip to content

Commit 7e5b60f

Browse files
committed
Use s.clear() instead of s=""
This avoids string table lookups.
1 parent 672e711 commit 7e5b60f

File tree

16 files changed

+29
-29
lines changed

16 files changed

+29
-29
lines changed

src/ansi-c/expr2c.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,13 @@ std::string expr2ct::convert_rec(
287287
if(width==config.ansi_c.int_width)
288288
{
289289
if(is_signed)
290-
sign_str="";
290+
sign_str.clear();
291291
return q+sign_str+"int"+d;
292292
}
293293
else if(width==config.ansi_c.long_int_width)
294294
{
295295
if(is_signed)
296-
sign_str="";
296+
sign_str.clear();
297297
return q+sign_str+"long int"+d;
298298
}
299299
else if(width==config.ansi_c.char_width)
@@ -304,19 +304,19 @@ std::string expr2ct::convert_rec(
304304
else if(width==config.ansi_c.short_int_width)
305305
{
306306
if(is_signed)
307-
sign_str="";
307+
sign_str.clear();
308308
return q+sign_str+"short int"+d;
309309
}
310310
else if(width==config.ansi_c.long_long_int_width)
311311
{
312312
if(is_signed)
313-
sign_str="";
313+
sign_str.clear();
314314
return q+sign_str+"long long int"+d;
315315
}
316316
else if(width==128)
317317
{
318318
if(is_signed)
319-
sign_str="";
319+
sign_str.clear();
320320
return q + sign_str + "__int128" + d;
321321
}
322322
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
@@ -1270,7 +1270,7 @@ void cpp_typecheck_resolvet::show_identifiers(
12701270
else if(id_expr.id() == ID_pod_constructor)
12711271
{
12721272
out << "constructor ";
1273-
id="";
1273+
id.clear();
12741274
}
12751275
else if(id_expr.id()==ID_template_function_instance)
12761276
{

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
@@ -438,7 +438,7 @@ void ms_cl_cmdlinet::process_cl_option(const std::string &s)
438438
if(s.size()==2)
439439
{
440440
option.islong=false;
441-
option.optstring="";
441+
option.optstring.clear();
442442
option.optchar=s[1];
443443
optnr=getoptnr(option.optchar);
444444
}
@@ -474,7 +474,7 @@ void ms_cl_cmdlinet::process_cl_option(const std::string &s)
474474
if(ms_cl_prefix.size()==1)
475475
{
476476
option.islong=false;
477-
option.optstring="";
477+
option.optstring.clear();
478478
option.optchar=ms_cl_prefix[0];
479479
optnr=getoptnr(option.optchar);
480480
}

src/goto-instrument/dump_c.cpp

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

@@ -504,7 +504,7 @@ void dump_ct::convert_compound(
504504
typedef_map.insert({typedef_str, typedef_infot(typedef_str)});
505505
PRECONDITION(!td_map_entry.second);
506506
if(!td_map_entry.first->second.early)
507-
td_map_entry.first->second.type_decl_str="";
507+
td_map_entry.first->second.type_decl_str.clear();
508508
os << "typedef ";
509509
}
510510

0 commit comments

Comments
 (0)