Kaydet (Commit) 03fcb4aa authored tarafından Noel Grandin's avatar Noel Grandin

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: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 39b39f12
......@@ -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
......
......@@ -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
......
......@@ -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: */
......@@ -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 )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment