From 3817965ded6c7ed915e4f9599e18b3e8abdaca44 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 12 May 2022 14:33:06 +0200 Subject: add SvStream::ReadLine(OStringBuffer... to reduce OString allocation and use it where possible Change-Id: I3efc7a642f73661ce606c917c0323ba9948521c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134265 Tested-by: Jenkins Reviewed-by: Noel Grandin --- oox/source/export/drawingml.cxx | 7 ++++--- oox/source/export/vmlexport.cxx | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'oox') diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index eb588076e213..18e6e2723e89 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -108,6 +108,7 @@ #include #include #include +#include #include #include #include @@ -3707,14 +3708,14 @@ static std::map< OString, std::vector > lcl_getAdjNames() SvFileStream aStream(aPath, StreamMode::READ); if (aStream.GetError() != ERRCODE_NONE) SAL_WARN("oox.shape", "failed to open oox-drawingml-adj-names"); - OString aLine; + OStringBuffer aLine; bool bNotDone = aStream.ReadLine(aLine); while (bNotDone) { sal_Int32 nIndex = 0; // Each line is in a "key\tvalue" format: read the key, the rest is the value. - OString aKey = aLine.getToken(0, '\t', nIndex); - OString aValue = aLine.copy(nIndex); + OString aKey( o3tl::getToken(aLine, 0, '\t', nIndex) ); + OString aValue( std::string_view(aLine).substr(nIndex) ); aRet[aKey].push_back(aValue); bNotDone = aStream.ReadLine(aLine); } diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index 32f60ff65c9a..8ee5c28ed67a 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -1138,13 +1138,13 @@ static std::vector lcl_getShapeTypes() SvFileStream aStream(aPath, StreamMode::READ); if (aStream.GetError() != ERRCODE_NONE) SAL_WARN("oox", "failed to open vml-shape-types"); - OString aLine; + OStringBuffer aLine; bool bNotDone = aStream.ReadLine(aLine); while (bNotDone) { // Filter out comments. - if (!aLine.startsWith("/")) - aRet.push_back(aLine); + if (!o3tl::starts_with(aLine, "/")) + aRet.push_back(OString(aLine)); bNotDone = aStream.ReadLine(aLine); } return aRet; -- cgit