[llvm] r358520 - [Support][JSON] Add reserve() to json Array

Anton Afanasyev via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 16 12:43:18 PDT 2019


Author: anton-afanasyev
Date: Tue Apr 16 12:43:18 2019
New Revision: 358520

URL: http://llvm.org/viewvc/llvm-project?rev=358520&view=rev
Log:
[Support][JSON] Add reserve() to json Array

Summary:
Space reservation increases json lib performance for the arrays with large number of entries.
Here is the example and discussion: https://reviews.llvm.org/D60609#1468941

Reviewers: lebedev.ri, sammccall

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60788

Modified:
    llvm/trunk/include/llvm/Support/JSON.h

Modified: llvm/trunk/include/llvm/Support/JSON.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/JSON.h?rev=358520&r1=358519&r2=358520&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/JSON.h (original)
+++ llvm/trunk/include/llvm/Support/JSON.h Tue Apr 16 12:43:18 2019
@@ -179,6 +179,7 @@ public:
 
   bool empty() const { return V.empty(); }
   size_t size() const { return V.size(); }
+  void reserve(size_t S) { V.reserve(S); }
 
   void clear() { V.clear(); }
   void push_back(const Value &E) { V.push_back(E); }




More information about the llvm-commits mailing list