Skip to content

Commit 13b3e4f

Browse files
committed
Use s.empty() or !s.empty() instead of comparison to irep_idt()
This avoids constructing an object when we can just use an integer comparison.
1 parent 29a9ce8 commit 13b3e4f

File tree

5 files changed

+8
-11
lines changed

5 files changed

+8
-11
lines changed

jbmc/src/java_bytecode/java_entry_point.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ main_function_resultt get_main_symbol(
542542
irep_idt main_symbol_id = resolve_friendly_method_name(
543543
config.main.value(), symbol_table, error_message);
544544

545-
if(main_symbol_id==irep_idt())
545+
if(main_symbol_id.empty())
546546
{
547547
message.error()
548548
<< "main symbol resolution failed: " << error_message << messaget::eom;

jbmc/src/java_bytecode/java_object_factory.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class recursion_set_entryt
290290
/// Removes erase_entry (if set) from the controlled set.
291291
~recursion_set_entryt()
292292
{
293-
if(erase_entry!=irep_idt())
293+
if(!erase_entry.empty())
294294
recursion_set.erase(erase_entry);
295295
}
296296

@@ -303,10 +303,8 @@ class recursion_set_entryt
303303
/// \return true if added to the set (and therefore owned by this object)
304304
bool insert_entry(const irep_idt &entry)
305305
{
306-
INVARIANT(
307-
erase_entry==irep_idt(),
308-
"insert_entry should only be called once");
309-
INVARIANT(entry!=irep_idt(), "entry should be a struct tag");
306+
INVARIANT(erase_entry.empty(), "insert_entry should only be called once");
307+
INVARIANT(!entry.empty(), "entry should be a struct tag");
310308
bool ret=recursion_set.insert(entry).second;
311309
if(ret)
312310
{

src/ansi-c/parser_static.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static void make_subtype(typet &dest, typet &src)
224224
}
225225
else if(p->is_nil())
226226
assert(false);
227-
else if(p->id()==irep_idt())
227+
else if(p->id().empty())
228228
assert(false);
229229
else
230230
{
@@ -247,7 +247,7 @@ static void make_subtype(typet &dest, typet &src)
247247
auto &merged_type = to_merged_type(*p);
248248
p=&merged_type.last_type();
249249
}
250-
else if(p->id()==irep_idt())
250+
else if(p->id().empty())
251251
assert(false);
252252
else if(p->is_nil())
253253
assert(false);

src/goto-programs/instrument_preconditions.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ replace_symbolt actuals_replace_map(
7575
std::size_t count=0;
7676
for(const auto &p : parameters)
7777
{
78-
if(p.get_identifier()!=irep_idt() &&
79-
arguments.size()>count)
78+
if(!p.get_identifier().empty() && arguments.size() > count)
8079
{
8180
const exprt a =
8281
typecast_exprt::conditional_cast(arguments[count], p.type());

src/solvers/smt2/smt2_conv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ constant_exprt smt2_convt::parse_literal(
317317

318318
mp_integer value;
319319

320-
if(src.id()!=irep_idt())
320+
if(!src.id().empty())
321321
{
322322
const std::string &s=src.id_string();
323323

0 commit comments

Comments
 (0)