Remove redundant string initialisation

Both std::string and dstringt are default-initialised to an empty string.
This commit is contained in:
Michael Tautschnig 2019-02-02 20:55:17 +00:00
parent ec56872cdc
commit c1baa03b2e
17 changed files with 17 additions and 18 deletions

View File

@ -277,7 +277,7 @@ std::string expr2javat::convert_rec(
// so we make one up, loosely inspired by the syntax
// of lambda expressions.
std::string dest="";
std::string dest;
dest+='(';
const java_method_typet::parameterst &parameters = method_type.parameters();

View File

@ -458,7 +458,7 @@ void local_may_aliast::output(
if(loc_info.aliases.find(j)==i)
{
assert(j<objects.size());
irep_idt identifier = "";
irep_idt identifier;
if(objects[j].id() == ID_symbol)
identifier = to_symbol_expr(objects[j]).get_identifier();
out << ' ' << from_expr(ns, identifier, objects[j]);

View File

@ -872,7 +872,7 @@ cpp_scopet &cpp_typecheck_resolvet::resolve_scope(
recursive=false;
}
std::string final_base_name="";
std::string final_base_name;
template_args.make_nil();
while(pos!=cpp_name.get_sub().end())

View File

@ -58,7 +58,7 @@ static void print_with_indent(
{
const std::size_t p = indent_line.find_first_not_of(" \t");
const std::string indent =
p == std::string::npos ? std::string("") : std::string(indent_line, 0, p);
p == std::string::npos ? std::string() : std::string(indent_line, 0, p);
std::istringstream in(src);
std::string src_line;
while(std::getline(in, src_line))

View File

@ -104,7 +104,7 @@ void dott::write_dot_subgraph(
if(it==instructions.end() ||
seen.find(it)!=seen.end()) continue;
std::stringstream tmp("");
std::stringstream tmp;
if(it->is_goto())
{
if(it->get_condition().is_true())

View File

@ -71,7 +71,6 @@ protected:
explicit typedef_infot(const irep_idt &name):
typedef_name(name),
type_decl_str(""),
early(false)
{
}

View File

@ -1864,7 +1864,7 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast)
// Replace by a function call to nondet_...
// We first search for a suitable one in the symbol table.
irep_idt id="";
irep_idt id;
for(symbol_tablet::symbolst::const_iterator
it=symbol_table.symbols.begin();
@ -1888,7 +1888,7 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast)
if(id.empty())
{
irep_idt base_name="";
irep_idt base_name;
if(expr.type().get(ID_C_c_type)!="")
{

View File

@ -949,7 +949,7 @@ bool string_abstractiont::build_symbol(const symbol_exprt &sym, exprt &dest)
const typet &abstract_type=build_abstraction_type(symbol.type);
CHECK_RETURN(!abstract_type.is_nil());
irep_idt identifier="";
irep_idt identifier;
if(current_args.find(symbol.name)!=current_args.end())
identifier=id2string(symbol.name)+arg_suffix;

View File

@ -55,7 +55,7 @@ propt::resultt qbf_qubet::prop_solve()
write_qdimacs_cnf(out);
}
std::string options="";
std::string options;
// solve it
int res=system(

View File

@ -51,7 +51,7 @@ propt::resultt qbf_qube_coret::prop_solve()
write_qdimacs_cnf(out);
}
std::string options="";
std::string options;
// solve it
int res=system((

View File

@ -55,7 +55,7 @@ propt::resultt qbf_skizzot::prop_solve()
write_qdimacs_cnf(out);
}
std::string options="";
std::string options;
// solve it
int res=system((

View File

@ -68,7 +68,7 @@ propt::resultt qbf_skizzo_coret::prop_solve()
write_qdimacs_cnf(out);
}
std::string options="";
std::string options;
// solve it
system((

View File

@ -138,7 +138,7 @@ std::string trim_from_last_delimiter(
const std::string &s,
const char delim)
{
std::string result="";
std::string result;
const size_t index=s.find_last_of(delim);
if(index!=std::string::npos)
result=s.substr(0, index);

View File

@ -213,7 +213,7 @@ void xmlt::set_attribute(
/// \return the unescaped string
std::string xmlt::unescape(const std::string &str)
{
std::string result("");
std::string result;
result.reserve(str.size());

View File

@ -59,7 +59,7 @@ void get_goto_model(std::istream &in, goto_modelt &goto_model)
language_filest language_files;
language_files.set_message_handler(null_message_handler);
std::string filename("");
std::string filename;
language_filet &language_file = language_files.add_file(filename);

View File

@ -16,7 +16,7 @@ Author: Diffblue Ltd.
/// given radix.
static size_t expected_length(unsigned long radix, const typet &type)
{
std::string longest("");
std::string longest;
if(radix == 2)
{
if(type == unsignedbv_typet(32))

View File

@ -107,7 +107,7 @@ SCENARIO("split_string", "[core][utils][string_utils][split_string]")
}
GIVEN("An empty string")
{
std::string string = "";
std::string string;
WHEN("Splitting it")
{
expected_resultst expected_results;