From 4e25e5066bfd6a1ea9d5dbfa5db9e25b66b8aa02 Mon Sep 17 00:00:00 2001 From: Hein-Pieter van Braam Date: Sun, 16 Dec 2018 00:44:18 +0000 Subject: Reduce String CoW By introducing an intermediate proxy class for the array subscript operator for String and CharString we can control better when CowData will actually CoW. This should improve performance of String usage for most cases. --- core/compressed_translation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/compressed_translation.cpp') diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp index 7dd5308fab..73affd8fe9 100644 --- a/core/compressed_translation.cpp +++ b/core/compressed_translation.cpp @@ -83,7 +83,7 @@ void PHashTranslation::generate(const Ref &p_from) { if (ps.orig_len != 0) { CharString dst_s; dst_s.resize(src_s.size()); - int ret = smaz_compress(src_s.get_data(), src_s.size(), &dst_s[0], src_s.size()); + int ret = smaz_compress(src_s.get_data(), src_s.size(), dst_s.ptrw(), src_s.size()); if (ret >= src_s.size()) { //if compressed is larger than original, just use original ps.orig_len = src_s.size(); -- cgit v1.2.3