diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-21 19:13:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-23 08:16:18 +0200 |
commit | d254f8a926d7d3ec4565d01f7a41ad3d9d7c9e87 (patch) | |
tree | 6f33b99f7344c3861972760428fb974073130d8d /tools | |
parent | 7c08c1af7116346f2dc0b669e231d82f4230a8c7 (diff) |
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/53263
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/generic/config.cxx | 49 |
1 files changed, 6 insertions, 43 deletions
diff --git a/tools/source/generic/config.cxx b/tools/source/generic/config.cxx index b5f392de5556..55ce2bdc03b8 100644 --- a/tools/source/generic/config.cxx +++ b/tools/source/generic/config.cxx @@ -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(); |