From f3157d94d1dfc219962bd598bb5cb80f482bb594 Mon Sep 17 00:00:00 2001 From: olowo726 Date: Thu, 11 Jul 2019 17:59:37 +0200 Subject: [PATCH 1/2] Made converters thread_local instead of local to function for performance --- runtime/Cpp/runtime/src/support/StringUtils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/Cpp/runtime/src/support/StringUtils.h b/runtime/Cpp/runtime/src/support/StringUtils.h index d0a0472a0..49715287e 100644 --- a/runtime/Cpp/runtime/src/support/StringUtils.h +++ b/runtime/Cpp/runtime/src/support/StringUtils.h @@ -22,7 +22,7 @@ namespace antlrcpp { inline std::string utf32_to_utf8(T const& data) { // Don't make the converter static or we have to serialize access to it. - UTF32Converter converter; + thread_local UTF32Converter converter; #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000 auto p = reinterpret_cast(data.data()); @@ -34,7 +34,7 @@ namespace antlrcpp { inline UTF32String utf8_to_utf32(const char* first, const char* last) { - UTF32Converter converter; + thread_local UTF32Converter converter; #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000 auto r = converter.from_bytes(first, last); From 06cee866d2cfb506ba0b160f2f78092168a59eba Mon Sep 17 00:00:00 2001 From: olowo726 Date: Thu, 11 Jul 2019 17:59:37 +0200 Subject: [PATCH 2/2] Made converters thread_local instead of local to function for performance --- contributors.txt | 3 ++- runtime/Cpp/runtime/src/support/StringUtils.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/contributors.txt b/contributors.txt index f4f4010c0..e7395e4a5 100644 --- a/contributors.txt +++ b/contributors.txt @@ -217,4 +217,5 @@ YYYY/MM/DD, github id, Full name, email 2019/02/06, ralucado, Cristina Raluca Vijulie, ralucris.v[at]gmail[dot]com 2019/03/13, base698, Justin Thomas, justin.thomas1@gmail.com 2019/03/18, carlodri, Carlo Dri, carlo.dri@gmail.com -2019/05/02, askingalot, Andy Collins, askingalot@gmail.com \ No newline at end of file +2019/05/02, askingalot, Andy Collins, askingalot@gmail.com +2019/07/11, olowo726, Olof Wolgast, olof@baah.se diff --git a/runtime/Cpp/runtime/src/support/StringUtils.h b/runtime/Cpp/runtime/src/support/StringUtils.h index d0a0472a0..49715287e 100644 --- a/runtime/Cpp/runtime/src/support/StringUtils.h +++ b/runtime/Cpp/runtime/src/support/StringUtils.h @@ -22,7 +22,7 @@ namespace antlrcpp { inline std::string utf32_to_utf8(T const& data) { // Don't make the converter static or we have to serialize access to it. - UTF32Converter converter; + thread_local UTF32Converter converter; #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000 auto p = reinterpret_cast(data.data()); @@ -34,7 +34,7 @@ namespace antlrcpp { inline UTF32String utf8_to_utf32(const char* first, const char* last) { - UTF32Converter converter; + thread_local UTF32Converter converter; #if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000 auto r = converter.from_bytes(first, last);