summaryrefslogtreecommitdiff
path: root/compilerplugins/clang
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-03 14:09:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-03 15:32:53 +0200
commitc5a0b7af847a71fd50f713934b29305f8ce96c6b (patch)
treed7c0193bc183250c36e467f830a4327ab94dc24e /compilerplugins/clang
parentd19dbcc139d18771e5e20e82a694f1512476e41c (diff)
loplugin:stringadd improvement for appending numbers
I was wrong, the Concat framework already optimised appending numbers by stack-allocating small buffers, so include them in the plugin Change-Id: I922edbdde273c89abfe21d51c5d25dc01c97db25 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115037 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r--compilerplugins/clang/stringadd.cxx16
1 files changed, 4 insertions, 12 deletions
diff --git a/compilerplugins/clang/stringadd.cxx b/compilerplugins/clang/stringadd.cxx
index 9c6d11fd55b1..c25992928f1e 100644
--- a/compilerplugins/clang/stringadd.cxx
+++ b/compilerplugins/clang/stringadd.cxx
@@ -277,12 +277,8 @@ bool StringAdd::VisitCXXMemberCallExpr(CXXMemberCallExpr const* methodCall)
&& !tc1.Class("OStringBuffer").Namespace("rtl").GlobalNamespace())
return true;
auto paramType = methodDecl->getParamDecl(0)->getType();
- // if we convert one of the number append methods, we need to create an extra temporary to hold the string convertion of the number
- if (paramType->isIntegerType())
- return true;
- if (paramType->isCharType())
- return true;
- if (paramType->isFloatingType())
+ // char is still a pain to work with, when constructing a chained +
+ if (paramType->isCharType() || loplugin::TypeCheck(paramType).Typedef("sal_Unicode"))
return true;
auto arg = methodCall->getArg(0);
// I don't think the OUStringAppend functionality can handle this efficiently
@@ -301,12 +297,8 @@ bool StringAdd::VisitCXXMemberCallExpr(CXXMemberCallExpr const* methodCall)
|| methodCall2->getNumArgs() == 0)
return true;
auto paramType2 = methodDecl2->getParamDecl(0)->getType();
- // if we convert one of the number append methods, we need to create an extra temporary to hold the string convertion of the number
- if (paramType2->isIntegerType())
- return true;
- if (paramType2->isCharType())
- return true;
- if (paramType2->isFloatingType())
+ // char is still a pain to work with, when constructing a chained +
+ if (paramType2->isCharType() || loplugin::TypeCheck(paramType2).Typedef("sal_Unicode"))
return true;
arg = methodCall2->getArg(0);
// I don't think the OUStringAppend functionality can handle this efficiently