diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-12 14:33:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-13 11:11:27 +0200 |
commit | 3817965ded6c7ed915e4f9599e18b3e8abdaca44 (patch) | |
tree | e112927919e8b7c9ce6c1e233ff6fce05f189784 /oox | |
parent | 8ad920befe1290c40ef762e8d7d9797b1924f5d2 (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/drawingml.cxx | 7 | ||||
-rw-r--r-- | oox/source/export/vmlexport.cxx | 6 |
2 files changed, 7 insertions, 6 deletions
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 <comphelper/xmltools.hxx> #include <o3tl/any.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <tools/stream.hxx> #include <unotools/fontdefs.hxx> #include <vcl/cvtgrf.hxx> @@ -3707,14 +3708,14 @@ static std::map< OString, std::vector<OString> > 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<OString> 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; |