public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libabigail@sourceware.org
Cc: Jonathan Wakely <jwakely@redhat.com>
Subject: [PATCH 1/4] Remove assertion with side-effects
Date: Mon, 01 Jan 2018 00:00:00 -0000	[thread overview]
Message-ID: <20180410142259.16175-1-jwakely@redhat.com> (raw)

Calling assert(split_string(...)) won't do anything when NDEBUG is
defined, but the split_string call can be avoided anyway.

Since only the first result from the split string is needed, and
remove_trailing_white_spaces will trim white space anyway, the overhead
of parsing it into a vector can be avoided by using std::string::substr
directly. Additionally, calling std::string::find with a single char is
more efficient than with a string.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
---
 src/abg-tools-utils.cc | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc
index 1f25ef3..60bb773 100644
--- a/src/abg-tools-utils.cc
+++ b/src/abg-tools-utils.cc
@@ -864,24 +864,10 @@ get_dsos_provided_by_rpm(const string& rpm_path, set<string>& provided_dsos)
        line != query_output.end();
        ++line)
     {
-      vector<string> splitted;
-      string dso;
-      if (!line->empty())
-	{
-	  if (line->find("(") != string::npos)
-	    {
-	      assert(split_string(*line, "(", splitted));
-	      dso = splitted.front();
-	    }
-	  else
-	    dso = *line;
-	}
-
+      string dso = line->substr(0, line->find('('));
+      dso = remove_trailing_white_spaces(dso);
       if (!dso.empty())
-	{
-	  dso = remove_trailing_white_spaces(dso);
-	  provided_dsos.insert(dso);
-	}
+	provided_dsos.insert(dso);
     }
   return true;
 }
-- 
2.13.6

             reply	other threads:[~2018-04-10 14:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-01  0:00 Jonathan Wakely [this message]
2018-01-01  0:00 ` [PATCH 4/4] Use std::string::substr instead of appending single chars Jonathan Wakely
2018-01-01  0:00   ` Dodji Seketeli
2018-01-01  0:00 ` [PATCH 3/4] Rename misleading remove_trailing_white_spaces functions Jonathan Wakely
2018-01-01  0:00   ` Dodji Seketeli
2018-01-01  0:00 ` [PATCH 2/4] Remove unused local set<string> variables Jonathan Wakely
2018-01-01  0:00   ` Dodji Seketeli
2018-01-01  0:00 ` [PATCH 1/4] Remove assertion with side-effects Dodji Seketeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180410142259.16175-1-jwakely@redhat.com \
    --to=jwakely@redhat.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).