diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-04 12:48:59 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-04 11:49:42 +0100 |
commit | a2058e7516a01167c2d20ed157500b38db967c64 (patch) | |
tree | 375dc0fd109e36bc490ee7e04d2201cee10e4cf2 /svx | |
parent | b156ca6e4692c2a32f41b9dfcd543966efc64a5d (diff) |
replace double-checked locking patterns with thread safe local statics
Change-Id: Ie1aae7ecbd065a88b371d8c0deb586f54f7eff65
Reviewed-on: https://gerrit.libreoffice.org/62835
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/table/tablecolumn.cxx | 76 | ||||
-rw-r--r-- | svx/source/table/tablerow.cxx | 76 |
2 files changed, 70 insertions, 82 deletions
diff --git a/svx/source/table/tablecolumn.cxx b/svx/source/table/tablecolumn.cxx index 183659670256..2342c6f10c87 100644 --- a/svx/source/table/tablecolumn.cxx +++ b/svx/source/table/tablecolumn.cxx @@ -234,47 +234,41 @@ Any SAL_CALL TableColumn::getFastPropertyValue( sal_Int32 nHandle ) rtl::Reference< FastPropertySetInfo > TableColumn::getStaticPropertySetInfo() { - static rtl::Reference< FastPropertySetInfo > xInfo; - if( !xInfo.is() ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is() ) - { - PropertyVector aProperties(6); - - aProperties[0].Name = "Width"; - aProperties[0].Handle = Property_Width; - aProperties[0].Type = ::cppu::UnoType<sal_Int32>::get(); - aProperties[0].Attributes = 0; - - aProperties[1].Name = "OptimalWidth"; - aProperties[1].Handle = Property_OptimalWidth; - aProperties[1].Type = cppu::UnoType<bool>::get(); - aProperties[1].Attributes = 0; - - aProperties[2].Name = "IsVisible"; - aProperties[2].Handle = Property_IsVisible; - aProperties[2].Type = cppu::UnoType<bool>::get(); - aProperties[2].Attributes = 0; - - aProperties[3].Name = "IsStartOfNewPage"; - aProperties[3].Handle = Property_IsStartOfNewPage; - aProperties[3].Type = cppu::UnoType<bool>::get(); - aProperties[3].Attributes = 0; - - aProperties[4].Name = "Size"; - aProperties[4].Handle = Property_Width; - aProperties[4].Type = ::cppu::UnoType<sal_Int32>::get(); - aProperties[4].Attributes = 0; - - aProperties[5].Name = "OptimalSize"; - aProperties[5].Handle = Property_OptimalWidth; - aProperties[5].Type = cppu::UnoType<bool>::get(); - aProperties[5].Attributes = 0; - - xInfo.set( new FastPropertySetInfo(aProperties) ); - } - } + static rtl::Reference<FastPropertySetInfo> xInfo = []() { + PropertyVector aProperties(6); + + aProperties[0].Name = "Width"; + aProperties[0].Handle = Property_Width; + aProperties[0].Type = ::cppu::UnoType<sal_Int32>::get(); + aProperties[0].Attributes = 0; + + aProperties[1].Name = "OptimalWidth"; + aProperties[1].Handle = Property_OptimalWidth; + aProperties[1].Type = cppu::UnoType<bool>::get(); + aProperties[1].Attributes = 0; + + aProperties[2].Name = "IsVisible"; + aProperties[2].Handle = Property_IsVisible; + aProperties[2].Type = cppu::UnoType<bool>::get(); + aProperties[2].Attributes = 0; + + aProperties[3].Name = "IsStartOfNewPage"; + aProperties[3].Handle = Property_IsStartOfNewPage; + aProperties[3].Type = cppu::UnoType<bool>::get(); + aProperties[3].Attributes = 0; + + aProperties[4].Name = "Size"; + aProperties[4].Handle = Property_Width; + aProperties[4].Type = ::cppu::UnoType<sal_Int32>::get(); + aProperties[4].Attributes = 0; + + aProperties[5].Name = "OptimalSize"; + aProperties[5].Handle = Property_OptimalWidth; + aProperties[5].Type = cppu::UnoType<bool>::get(); + aProperties[5].Attributes = 0; + + return rtl::Reference<FastPropertySetInfo>(new FastPropertySetInfo(aProperties)); + }(); return xInfo; } diff --git a/svx/source/table/tablerow.cxx b/svx/source/table/tablerow.cxx index 87cba24d12cd..d1dd1f371800 100644 --- a/svx/source/table/tablerow.cxx +++ b/svx/source/table/tablerow.cxx @@ -308,47 +308,41 @@ Any SAL_CALL TableRow::getFastPropertyValue( sal_Int32 nHandle ) rtl::Reference< FastPropertySetInfo > TableRow::getStaticPropertySetInfo() { - static rtl::Reference< FastPropertySetInfo > xInfo; - if( !xInfo.is() ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is() ) - { - PropertyVector aProperties(6); - - aProperties[0].Name = "Height"; - aProperties[0].Handle = Property_Height; - aProperties[0].Type = ::cppu::UnoType<sal_Int32>::get(); - aProperties[0].Attributes = 0; - - aProperties[1].Name = "OptimalHeight"; - aProperties[1].Handle = Property_OptimalHeight; - aProperties[1].Type = cppu::UnoType<bool>::get(); - aProperties[1].Attributes = 0; - - aProperties[2].Name = "IsVisible"; - aProperties[2].Handle = Property_IsVisible; - aProperties[2].Type = cppu::UnoType<bool>::get(); - aProperties[2].Attributes = 0; - - aProperties[3].Name = "IsStartOfNewPage"; - aProperties[3].Handle = Property_IsStartOfNewPage; - aProperties[3].Type = cppu::UnoType<bool>::get(); - aProperties[3].Attributes = 0; - - aProperties[4].Name = "Size"; - aProperties[4].Handle = Property_Height; - aProperties[4].Type = ::cppu::UnoType<sal_Int32>::get(); - aProperties[4].Attributes = 0; - - aProperties[5].Name = "OptimalSize"; - aProperties[5].Handle = Property_OptimalHeight; - aProperties[5].Type = cppu::UnoType<bool>::get(); - aProperties[5].Attributes = 0; - - xInfo.set( new FastPropertySetInfo(aProperties) ); - } - } + static rtl::Reference<FastPropertySetInfo> xInfo = []() { + PropertyVector aProperties(6); + + aProperties[0].Name = "Height"; + aProperties[0].Handle = Property_Height; + aProperties[0].Type = ::cppu::UnoType<sal_Int32>::get(); + aProperties[0].Attributes = 0; + + aProperties[1].Name = "OptimalHeight"; + aProperties[1].Handle = Property_OptimalHeight; + aProperties[1].Type = cppu::UnoType<bool>::get(); + aProperties[1].Attributes = 0; + + aProperties[2].Name = "IsVisible"; + aProperties[2].Handle = Property_IsVisible; + aProperties[2].Type = cppu::UnoType<bool>::get(); + aProperties[2].Attributes = 0; + + aProperties[3].Name = "IsStartOfNewPage"; + aProperties[3].Handle = Property_IsStartOfNewPage; + aProperties[3].Type = cppu::UnoType<bool>::get(); + aProperties[3].Attributes = 0; + + aProperties[4].Name = "Size"; + aProperties[4].Handle = Property_Height; + aProperties[4].Type = ::cppu::UnoType<sal_Int32>::get(); + aProperties[4].Attributes = 0; + + aProperties[5].Name = "OptimalSize"; + aProperties[5].Handle = Property_OptimalHeight; + aProperties[5].Type = cppu::UnoType<bool>::get(); + aProperties[5].Attributes = 0; + + return rtl::Reference<FastPropertySetInfo>(new FastPropertySetInfo(aProperties)); + }(); return xInfo; } |