From 765f0183815556be357429dbc3421fcb00e0e920 Mon Sep 17 00:00:00 2001 From: Anton Afanasyev Date: Tue, 16 Apr 2019 19:43:18 +0000 Subject: [PATCH] [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 llvm-svn: 358520 --- llvm/include/llvm/Support/JSON.h | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/include/llvm/Support/JSON.h b/llvm/include/llvm/Support/JSON.h index e3cb95066323..b2aaf68724d6 100644 --- a/llvm/include/llvm/Support/JSON.h +++ b/llvm/include/llvm/Support/JSON.h @@ -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); }