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

loplugin:singlevalfields improve unaryoperator

when we see a unaryoperator, unless it's one of a small set, we can
know (mostly) that the field will not be written.
there is still a small risk of false+ with code taking references
via conditional expressions.

Change-Id: I96fa808067576a50e5eaf425338e225b4e0bdd4e
Reviewed-on: https://gerrit.libreoffice.org/53263Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 7c08c1af
......@@ -212,7 +212,6 @@ SbiTokenizer::SbiTokenizer( const OUString& rSrc, StarBASIC* pb )
, nPCol2(0)
, bEof(false)
, bEos(true)
, bKeywords(true)
, bAs(false)
, bErrorIsSymbol(true)
{
......@@ -362,8 +361,7 @@ SbiToken SbiTokenizer::Next()
}
else
{
if( eScanType != SbxVARIANT
|| ( !bKeywords && bSymbol ) )
if( eScanType != SbxVARIANT )
return eCurTok = SYMBOL;
// valid token?
short lb = 0;
......
......@@ -107,7 +107,6 @@ protected:
sal_uInt16 nPLine, nPCol1, nPCol2; // pushback location
bool bEof;
bool bEos;
bool bKeywords; // true, if keywords are parsed
bool bAs; // last keyword was AS
bool bErrorIsSymbol; // Handle Error token as Symbol, not keyword
public:
......
......@@ -307,8 +307,8 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
bPotentiallyAssignedTo = true;
break;
}
child = parent;
parent = getParentStmt(parent);
// cannot be assigned to anymore
break;
}
else if (isa<CallExpr>(parent))
{
......
basic/source/inc/token.hxx:110
SbiTokenizer bKeywords
1
chart2/source/model/main/DataPoint.hxx:107
chart::DataPoint m_bNoParentPropAllowed
0
chart2/source/view/inc/GL3DRenderer.hxx:161
chart::opengl3D::TextInfoBatch batchNum
512
connectivity/source/inc/dbase/DIndexIter.hxx:37
connectivity::dbase::OIndexIterator m_pOperand
0
include/basic/sbxvar.hxx:70
SbxValues::(anonymous) pData
0
......@@ -19,18 +25,30 @@ include/filter/msfilter/dffpropset.hxx:35
include/o3tl/vector_pool.hxx:93
o3tl::detail::struct_from_value::type nextFree
-1
include/sfx2/charwin.hxx:105
SvxCharViewControl maHasInsert
include/oox/dump/dumperbase.hxx:1661
oox::dump::RecordObjectBase mbBinaryOnly
0
include/oox/ole/axcontrol.hxx:427
oox::ole::ComCtlModelBase mbCommonPart
1
include/oox/ole/axcontrol.hxx:428
oox::ole::ComCtlModelBase mbComplexPart
1
include/svtools/HtmlWriter.hxx:29
HtmlWriter mbContentWritten
0
include/svtools/svparser.hxx:74
SvParser::TokenStackType nTokenValue
0
include/svtools/svparser.hxx:75
SvParser::TokenStackType bTokenHasValue
0
include/svx/svdograf.hxx:107
SdrGrafObj mbIsPreview
include/svx/svdviter.hxx:73
SdrViewIter mbNoMasterPage
0
include/tools/config.hxx:36
Config mnLockCount
1
include/vcl/filter/pdfdocument.hxx:174
vcl::filter::PDFNameElement m_nLength
0
......@@ -136,6 +154,15 @@ sw/source/filter/ww8/ww8par.hxx:655
sw/source/filter/ww8/ww8par.hxx:664
WW8FormulaControl mhpsCheckBox
20
sw/source/uibase/inc/envlop.hxx:66
SwEnvDlg pAddresseeSet
0
sw/source/uibase/inc/envlop.hxx:67
SwEnvDlg pSenderSet
0
unotools/source/config/saveopt.cxx:77
SvtSaveOptions_Impl bROUserAutoSave
0
vcl/inc/salprn.hxx:41
SalPrinterQueueInfo mnStatus
0
......@@ -157,6 +184,9 @@ vcl/inc/svdata.hxx:285
vcl/inc/svdata.hxx:287
ImplSVNWFData mbProgressNeedsErase
0
vcl/source/control/morebtn.cxx:26
ImplMoreButtonData mpItemList
0
vcl/source/filter/jpeg/transupp.h:128
(anonymous) perfect
0
......
......@@ -26,7 +26,6 @@ private:
SvStream& mrStream;
bool mbElementOpen;
bool mbContentWritten;
bool mbCharactersWritten;
bool mbPrettyPrint;
/// XML namespace, in case of XHTML.
......
......@@ -144,7 +144,6 @@ using TransferableHelper::CopyToClipboard;
sal_uInt32 mnObjectPos;
tools::SvRef<SotStorageStream> mxModelStream;
GraphicObject* mpGraphicObject;
ImageMap* mpImageMap;
INetURLObject* mpURL;
GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObjectPos, bool bLazy );
......
......@@ -70,8 +70,6 @@ class SVX_DLLPUBLIC SdrViewIter
size_t mnListenerNum;
bool mbNoMasterPage : 1;
private:
SVX_DLLPRIVATE void ImpInitVars();
SVX_DLLPRIVATE SdrView* ImpFindView();
......
......@@ -33,7 +33,6 @@ private:
ImplConfigData* mpData;
ImplGroupData* mpActGroup;
sal_uInt32 mnDataUpdateId;
sal_uInt16 mnLockCount;
TOOLS_DLLPRIVATE bool ImplUpdateConfig() const;
TOOLS_DLLPRIVATE ImplGroupData* ImplGetGroup() const;
......
......@@ -50,9 +50,6 @@ void LotusFontBuffer::Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet )
if( pCurrent->pHeight )
rItemSet.Put( *pCurrent->pHeight );
if( pCurrent->pColor )
rItemSet.Put( *pCurrent->pColor );
if( nIndex & 0x08 )
{
SvxWeightItem aWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT );
......
......@@ -35,14 +35,12 @@ private:
OUString* pTmpName;
SvxFontItem* pFont;
SvxFontHeightItem* pHeight;
SvxColorItem* pColor;
sal_Int32 nType; // < 0 -> undefiniert
sal_Int32 nType; // < 0 -> undefined
ENTRY()
{
pTmpName = nullptr;
pFont = nullptr;
pHeight = nullptr;
pColor = nullptr;
nType = -1;
}
~ENTRY()
......@@ -53,8 +51,6 @@ private:
delete pFont;
if( pHeight )
delete pHeight;
if( pColor )
delete pColor;
}
void TmpName( const OUString &rNew )
{
......
......@@ -14,7 +14,6 @@
HtmlWriter::HtmlWriter(SvStream& rStream, const OString& rNamespace) :
mrStream(rStream),
mbElementOpen(false),
mbContentWritten(false),
mbCharactersWritten(false),
mbPrettyPrint(true)
{
......@@ -38,9 +37,8 @@ void HtmlWriter::start(const OString& aElement)
if (mbElementOpen)
{
mrStream.WriteChar('>');
if (!mbContentWritten && mbPrettyPrint)
if (mbPrettyPrint)
mrStream.WriteChar('\n');
mbContentWritten = false;
}
maElementStack.push_back(aElement);
......@@ -92,7 +90,7 @@ void HtmlWriter::end()
}
else
{
if (!mbContentWritten && mbPrettyPrint)
if (mbPrettyPrint)
{
for(size_t i = 0; i < maElementStack.size() - 1; i++)
{
......@@ -107,7 +105,6 @@ void HtmlWriter::end()
}
maElementStack.pop_back();
mbElementOpen = false;
mbContentWritten = false;
mbCharactersWritten = false;
}
......
......@@ -380,7 +380,6 @@ GalleryTransferable::GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObje
meObjectKind( mpTheme->GetObjectKind( nObjectPos ) ),
mnObjectPos( nObjectPos ),
mpGraphicObject( nullptr ),
mpImageMap( nullptr ),
mpURL( nullptr )
{
......@@ -496,11 +495,6 @@ bool GalleryTransferable::GetData( const datatransfer::DataFlavor& rFlavor, cons
{
bRet = ( mxModelStream.is() && SetObject( mxModelStream.get(), 0, rFlavor ) );
}
else if( ( SotClipboardFormatId::SVIM == nFormat ) && mpImageMap )
{
// TODO/MBA: do we need a BaseURL here?!
bRet = SetImageMap( *mpImageMap );
}
else if( ( SotClipboardFormatId::SIMPLE_FILE == nFormat ) && mpURL )
{
bRet = SetString( mpURL->GetMainURL( INetURLObject::DecodeMechanism::NONE ), rFlavor );
......@@ -552,8 +546,6 @@ void GalleryTransferable::ObjectReleased()
mxModelStream.clear();
delete mpGraphicObject;
mpGraphicObject = nullptr;
delete mpImageMap;
mpImageMap = nullptr;
delete mpURL;
mpURL = nullptr;
}
......
......@@ -40,7 +40,6 @@ SdrViewIter::SdrViewIter(const SdrPage* pPage)
mpPage = pPage;
mpModel = pPage ? &pPage->getSdrModelFromSdrPage() : nullptr;
mpObject = nullptr;
mbNoMasterPage = false;
ImpInitVars();
}
......@@ -50,7 +49,6 @@ SdrViewIter::SdrViewIter(const SdrObject* pObject)
mpObject = pObject;
mpModel = pObject ? &pObject->getSdrModelFromSdrObject() : nullptr;
mpPage = pObject ? pObject->GetPage() : nullptr;
mbNoMasterPage = false;
if(!mpModel || !mpPage)
{
......@@ -86,7 +84,7 @@ bool SdrViewIter::ImpCheckPageView(SdrPageView const * pPV) const
return true;
}
}
else if(!mbNoMasterPage && bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
else if(bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
{
if(pPg->TRG_HasMasterPage())
{
......
......@@ -658,7 +658,6 @@ Config::Config( const OUString& rFileName )
mpData = ImplGetConfigData( maFileName );
mpActGroup = nullptr;
mnDataUpdateId = 0;
mnLockCount = 1;
SAL_INFO("tools.generic", "Config::Config( " << maFileName << " )");
}
......@@ -684,7 +683,7 @@ void Config::SetGroup(const OString& rGroup)
void Config::DeleteGroup(const OString& rGroup)
{
// Update config data if necessary
if ( !mnLockCount || !mpData->mbRead )
if ( !mpData->mbRead )
{
ImplUpdateConfig();
mpData->mbRead = true;
......@@ -721,12 +720,7 @@ void Config::DeleteGroup(const OString& rGroup)
delete pGroup;
// Rewrite config data
if ( !mnLockCount )
ImplWriteConfig( mpData );
else
{
mpData->mbModified = true;
}
mpData->mbModified = true;
mnDataUpdateId = mpData->mnDataUpdateId;
mpData->mnDataUpdateId++;
......@@ -735,10 +729,6 @@ void Config::DeleteGroup(const OString& rGroup)
OString Config::GetGroupName(sal_uInt16 nGroup) const
{
// Update config data if necessary
if ( !mnLockCount )
ImplUpdateConfig();
ImplGroupData* pGroup = mpData->mpFirstGroup;
sal_uInt16 nGroupCount = 0;
OString aGroupName;
......@@ -759,10 +749,6 @@ OString Config::GetGroupName(sal_uInt16 nGroup) const
sal_uInt16 Config::GetGroupCount() const
{
// Update config data if necessary
if ( !mnLockCount )
ImplUpdateConfig();
ImplGroupData* pGroup = mpData->mpFirstGroup;
sal_uInt16 nGroupCount = 0;
while ( pGroup )
......@@ -776,10 +762,6 @@ sal_uInt16 Config::GetGroupCount() const
bool Config::HasGroup(const OString& rGroup) const
{
// Update config data if necessary
if ( !mnLockCount )
ImplUpdateConfig();
ImplGroupData* pGroup = mpData->mpFirstGroup;
bool bRet = false;
......@@ -807,10 +789,6 @@ OString Config::ReadKey(const OString& rKey, const OString& rDefault) const
SAL_INFO("tools.generic", "Config::ReadKey( " << rKey << " ) from " << GetGroup()
<< " in " << maFileName);
// Update config data if necessary
if ( !mnLockCount )
ImplUpdateConfig();
// Search key, return value if found
ImplGroupData* pGroup = ImplGetGroup();
if ( pGroup )
......@@ -834,7 +812,7 @@ void Config::WriteKey(const OString& rKey, const OString& rStr)
<< GetGroup() << " in " << maFileName);
// Update config data if necessary
if ( !mnLockCount || !mpData->mbRead )
if ( !mpData->mbRead )
{
ImplUpdateConfig();
mpData->mbRead = true;
......@@ -875,12 +853,7 @@ void Config::WriteKey(const OString& rKey, const OString& rStr)
{
pKey->maValue = rStr;
if ( !mnLockCount )
ImplWriteConfig( mpData );
else
{
mpData->mbModified = true;
}
mpData->mbModified = true;
}
}
}
......@@ -888,7 +861,7 @@ void Config::WriteKey(const OString& rKey, const OString& rStr)
void Config::DeleteKey(const OString& rKey)
{
// Update config data if necessary
if ( !mnLockCount || !mpData->mbRead )
if ( !mpData->mbRead )
{
ImplUpdateConfig();
mpData->mbRead = true;
......@@ -918,13 +891,7 @@ void Config::DeleteKey(const OString& rKey)
pGroup->mpFirstKey = pKey->mpNext;
delete pKey;
// Rewrite config file
if ( !mnLockCount )
ImplWriteConfig( mpData );
else
{
mpData->mbModified = true;
}
mpData->mbModified = true;
}
}
}
......@@ -933,10 +900,6 @@ sal_uInt16 Config::GetKeyCount() const
{
SAL_INFO("tools.generic", "Config::GetKeyCount() from " << GetGroup() << " in " << maFileName);
// Update config data if necessary
if ( !mnLockCount )
ImplUpdateConfig();
// Search key and update value
sal_uInt16 nCount = 0;
ImplGroupData* pGroup = ImplGetGroup();
......
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