diff mbox series

[3/3] abg-reader: create a fresh corpus object per corpus

Message ID 20210427112853.1338240-4-gprocida@google.com
State New
Headers show
Series always create fresh corpus objects | expand

Commit Message

Giuliano Procida April 27, 2021, 11:28 a.m. UTC
Currently the XML reader reuses the same corpus object for all
corpora in a corpus group. This has an unwanted side-effect: any
abi-instr with the same path in different corpora will collide and
parts of the ABI will be lost.

Creating a new corpus object for every abi-corpus element seems like
the right thing to do. Testing with large ABIs containing many corpora
also shows a modest (~10%) abidiff speed improvement.

	* src/abg-reader.cc (read_corpus_from_input): Always create a
	fresh corpus object for each abi-corpus XML element.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-reader.cc | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/src/abg-reader.cc b/src/abg-reader.cc
index 313af4c9..e32c9bf3 100644
--- a/src/abg-reader.cc
+++ b/src/abg-reader.cc
@@ -1776,11 +1776,7 @@  read_corpus_from_input(read_context& ctxt)
 				       BAD_CAST("abi-corpus")))
 	return nil;
 
-      if (!ctxt.get_corpus())
-	{
-	  corpus_sptr c(new corpus(ctxt.get_environment(), ""));
-	  ctxt.set_corpus(c);
-	}
+      ctxt.set_corpus(std::make_shared<corpus>(ctxt.get_environment(), ""));
 
       if (!ctxt.get_corpus_group())
 	ctxt.clear_per_corpus_data();
@@ -1834,11 +1830,7 @@  read_corpus_from_input(read_context& ctxt)
     }
   else
     {
-      if (!ctxt.get_corpus())
-	{
-	  corpus_sptr c(new corpus(ctxt.get_environment(), ""));
-	  ctxt.set_corpus(c);
-	}
+      ctxt.set_corpus(std::make_shared<corpus>(ctxt.get_environment(), ""));
 
       if (!ctxt.get_corpus_group())
 	ctxt.clear_per_corpus_data();