sequence->vector in OSimpleLogRing

Change-Id: Ief35ce33a11c93a4a78e50ccdd936ec7e17102a2
This commit is contained in:
Noel Grandin
2016-01-28 15:15:19 +02:00
parent ba03604b55
commit 31f1294163
2 changed files with 6 additions and 5 deletions

View File

@@ -78,7 +78,7 @@ void SAL_CALL OSimpleLogRing::logString( const OUString& aMessage ) throw (uno::
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
m_aMessages[m_nPos] = aMessage; m_aMessages[m_nPos] = aMessage;
if ( ++m_nPos >= m_aMessages.getLength() ) if ( ++m_nPos >= (sal_Int32)m_aMessages.size() )
{ {
m_nPos = 0; m_nPos = 0;
m_bFull = true; m_bFull = true;
@@ -93,12 +93,12 @@ uno::Sequence< OUString > SAL_CALL OSimpleLogRing::getCollectedLog() throw (uno:
{ {
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
sal_Int32 nResLen = m_bFull ? m_aMessages.getLength() : m_nPos; sal_Int32 nResLen = m_bFull ? m_aMessages.size() : m_nPos;
sal_Int32 nStart = m_bFull ? m_nPos : 0; sal_Int32 nStart = m_bFull ? m_nPos : 0;
uno::Sequence< OUString > aResult( nResLen ); uno::Sequence< OUString > aResult( nResLen );
for ( sal_Int32 nInd = 0; nInd < nResLen; nInd++ ) for ( sal_Int32 nInd = 0; nInd < nResLen; nInd++ )
aResult[nInd] = m_aMessages[ ( nStart + nInd ) % m_aMessages.getLength() ]; aResult[nInd] = m_aMessages[ ( nStart + nInd ) % m_aMessages.size() ];
// if used once then default initialized // if used once then default initialized
m_bInitialized = true; m_bInitialized = true;
@@ -121,7 +121,7 @@ void SAL_CALL OSimpleLogRing::initialize( const uno::Sequence< uno::Any >& aArgu
{ {
sal_Int32 nLen = 0; sal_Int32 nLen = 0;
if ( aArguments.getLength() == 1 && ( aArguments[0] >>= nLen ) && nLen ) if ( aArguments.getLength() == 1 && ( aArguments[0] >>= nLen ) && nLen )
m_aMessages.realloc( nLen ); m_aMessages.resize( nLen );
else else
throw lang::IllegalArgumentException( throw lang::IllegalArgumentException(
"Nonnull size is expected as the first argument!", "Nonnull size is expected as the first argument!",

View File

@@ -26,6 +26,7 @@
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase.hxx>
#include <vector>
#define SIMPLELOGRING_SIZE 256 #define SIMPLELOGRING_SIZE 256
@@ -37,7 +38,7 @@ class OSimpleLogRing : public ::cppu::WeakImplHelper< css::logging::XSimpleLogRi
css::lang::XServiceInfo > css::lang::XServiceInfo >
{ {
::osl::Mutex m_aMutex; ::osl::Mutex m_aMutex;
css::uno::Sequence< OUString > m_aMessages; std::vector< OUString > m_aMessages;
bool m_bInitialized; bool m_bInitialized;
bool m_bFull; bool m_bFull;