summaryrefslogtreecommitdiff
path: root/idlc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-12-21 14:35:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-12-22 08:16:55 +0100
commit03fcb4aae62a9403f22ec3671b61555419d02514 (patch)
tree87d0a30c633d4171fad55df469531c12380aca0c /idlc
parent39b39f124a2bd6abe62e30bacac5d1326495d862 (diff)
idlc: no need to store single OString objects on the heap
Change-Id: I26586ed643d34690b56e40691df9b493a34afa16 Reviewed-on: https://gerrit.libreoffice.org/65536 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'idlc')
-rw-r--r--idlc/inc/astexpression.hxx5
-rw-r--r--idlc/inc/astsequence.hxx2
-rw-r--r--idlc/source/astdump.cxx8
-rw-r--r--idlc/source/astexpression.cxx15
4 files changed, 16 insertions, 14 deletions
diff --git a/idlc/inc/astexpression.hxx b/idlc/inc/astexpression.hxx
index 68f8c4e4a937..03e47004c232 100644
--- a/idlc/inc/astexpression.hxx
+++ b/idlc/inc/astexpression.hxx
@@ -24,6 +24,7 @@
#include <memory>
#include "idlc.hxx"
+#include <boost/optional.hpp>
// Enum to define all the different operators to combine expressions
enum class ExprComb
@@ -133,8 +134,8 @@ private:
m_subExpr2;
std::unique_ptr<AstExprValue>
m_exprValue;
- std::unique_ptr<OString>
- m_pSymbolicName;
+ boost::optional<OString>
+ m_xSymbolicName;
};
#endif // INCLUDED_IDLC_INC_ASTEXPRESSION_HXX
diff --git a/idlc/inc/astsequence.hxx b/idlc/inc/astsequence.hxx
index 5daedf1476d6..229b17dbd2f7 100644
--- a/idlc/inc/astsequence.hxx
+++ b/idlc/inc/astsequence.hxx
@@ -38,7 +38,7 @@ public:
virtual const sal_Char* getRelativName() const override;
private:
AstType const * m_pMemberType;
- mutable std::unique_ptr<OString> m_pRelativName;
+ mutable boost::optional<OString> m_xRelativName;
};
#endif // INCLUDED_IDLC_INC_ASTSEQUENCE_HXX
diff --git a/idlc/source/astdump.cxx b/idlc/source/astdump.cxx
index f3e82bda03a0..6038c4af7997 100644
--- a/idlc/source/astdump.cxx
+++ b/idlc/source/astdump.cxx
@@ -406,14 +406,14 @@ void AstAttribute::dumpExceptions(
const sal_Char* AstSequence::getRelativName() const
{
- if ( !m_pRelativName )
+ if ( !m_xRelativName )
{
- m_pRelativName.reset( new OString("[]") );
+ m_xRelativName = OString("[]");
AstDeclaration const * pType = resolveTypedefs( m_pMemberType );
- *m_pRelativName += pType->getRelativName();
+ *m_xRelativName += pType->getRelativName();
}
- return m_pRelativName->getStr();
+ return m_xRelativName->getStr();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/idlc/source/astexpression.cxx b/idlc/source/astexpression.cxx
index 67277376832b..f9f91a719435 100644
--- a/idlc/source/astexpression.cxx
+++ b/idlc/source/astexpression.cxx
@@ -91,8 +91,9 @@ AstExpression::AstExpression(double d)
AstExpression::AstExpression(OString* scopedName)
: m_combOperator(ExprComb::Symbol)
- , m_pSymbolicName(scopedName)
{
+ if (scopedName)
+ m_xSymbolicName = *scopedName;
fillDefinitionDetails();
}
@@ -877,7 +878,7 @@ std::unique_ptr<AstExprValue> AstExpression::eval_symbol()
/*
* Is there a symbol stored?
*/
- if (m_pSymbolicName == nullptr)
+ if (!m_xSymbolicName)
{
ErrorHandler::evalError(this);
return nullptr;
@@ -889,16 +890,16 @@ std::unique_ptr<AstExprValue> AstExpression::eval_symbol()
pScope = idlc()->scopes()->topNonNull();
if ( !pScope )
{
- ErrorHandler::lookupError(*m_pSymbolicName);
+ ErrorHandler::lookupError(*m_xSymbolicName);
return nullptr;
}
/*
* Do lookup
*/
- pDecl = pScope->lookupByName(*m_pSymbolicName);
+ pDecl = pScope->lookupByName(*m_xSymbolicName);
if (pDecl == nullptr)
{
- ErrorHandler::lookupError(*m_pSymbolicName);
+ ErrorHandler::lookupError(*m_xSymbolicName);
return nullptr;
}
/*
@@ -907,7 +908,7 @@ std::unique_ptr<AstExprValue> AstExpression::eval_symbol()
if (pDecl->getNodeType() != NT_const &&
pDecl->getNodeType() != NT_enum_val)
{
- ErrorHandler::constantExpected(pDecl, *m_pSymbolicName);
+ ErrorHandler::constantExpected(pDecl, *m_xSymbolicName);
return nullptr;
}
if (!ErrorHandler::checkPublished(pDecl))
@@ -927,7 +928,7 @@ OString AstExpression::toString()
{
OString exprStr;
if ( m_combOperator == ExprComb::Symbol )
- return m_pSymbolicName ? *m_pSymbolicName : OString("<Undefined Name>");
+ return m_xSymbolicName ? *m_xSymbolicName : OString("<Undefined Name>");
if ( m_exprValue )
{