From 827b218b94c64b658549bd0d4468783a7f1e231a Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 22 Feb 2022 00:10:31 +0100 Subject: merge poolio.cxx into itempool.cxx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It doesn't make sense to have few SfxItemPool functions in a separate source file, and without LTO those tiny functions do not get inlined, which is confusing when profiling. Change-Id: I0ba891ba51c7d8dd3eba3f4cae0f7819f9b033e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130327 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- svl/Library_svl.mk | 1 - svl/source/items/itempool.cxx | 67 ++++++++++++++++++++++++++++++ svl/source/items/poolio.cxx | 95 ------------------------------------------- 3 files changed, 67 insertions(+), 96 deletions(-) delete mode 100644 svl/source/items/poolio.cxx (limited to 'svl') diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk index 8dd746b2462c..116f9ba416af 100644 --- a/svl/Library_svl.mk +++ b/svl/Library_svl.mk @@ -133,7 +133,6 @@ $(eval $(call gb_Library_add_exception_objects,svl,\ svl/source/items/legacyitem \ svl/source/items/macitem \ svl/source/items/poolcach \ - svl/source/items/poolio \ svl/source/items/poolitem \ svl/source/items/ptitem \ svl/source/items/rectitem \ diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index e13a1ffd60ea..579aad4005f8 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -86,6 +86,73 @@ do { \ #define CHECK_SLOTS() do {} while (false) #endif +/// clear array of PoolItem variants +/// after all PoolItems are deleted +/// or all ref counts are decreased +void SfxPoolItemArray_Impl::clear() +{ + maPoolItemSet.clear(); + maSortablePoolItems.clear(); +} + +sal_uInt16 SfxItemPool::GetFirstWhich() const +{ + return pImpl->mnStart; +} + +sal_uInt16 SfxItemPool::GetLastWhich() const +{ + return pImpl->mnEnd; +} + +bool SfxItemPool::IsInRange( sal_uInt16 nWhich ) const +{ + return nWhich >= pImpl->mnStart && nWhich <= pImpl->mnEnd; +} + +sal_uInt16 SfxItemPool::GetIndex_Impl(sal_uInt16 nWhich) const +{ + if (nWhich < pImpl->mnStart || nWhich > pImpl->mnEnd) + { + assert(false && "missing bounds check before use"); + return 0; + } + return nWhich - pImpl->mnStart; +} + +sal_uInt16 SfxItemPool::GetSize_Impl() const +{ + return pImpl->mnEnd - pImpl->mnStart + 1; +} + + +bool SfxItemPool::CheckItemInPool(const SfxPoolItem *pItem) const +{ + DBG_ASSERT( pItem, "no 0-Pointer Surrogate" ); + DBG_ASSERT( !IsInvalidItem(pItem), "no Invalid-Item Surrogate" ); + DBG_ASSERT( !IsPoolDefaultItem(pItem), "no Pool-Default-Item Surrogate" ); + + if ( !IsInRange(pItem->Which()) ) + { + if ( pImpl->mpSecondary ) + return pImpl->mpSecondary->CheckItemInPool( pItem ); + SAL_WARN( "svl.items", "unknown Which-Id - don't ask me for surrogates, with ID/pos " << pItem->Which()); + } + + // Pointer on static or pool-default attribute? + if( IsStaticDefaultItem(pItem) || IsPoolDefaultItem(pItem) ) + return true; + + SfxPoolItemArray_Impl& rItemArr = pImpl->maPoolItemArrays[GetIndex_Impl(pItem->Which())]; + + for ( auto p : rItemArr ) + { + if ( p == pItem ) + return true; + } + SAL_WARN( "svl.items", "Item not in the pool, with ID/pos " << pItem->Which()); + return false; +} const SfxPoolItem* SfxItemPool::GetPoolDefaultItem( sal_uInt16 nWhich ) const { diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx deleted file mode 100644 index 14613824eae4..000000000000 --- a/svl/source/items/poolio.cxx +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include - -#include -#include - -#include - -/// clear array of PoolItem variants -/// after all PoolItems are deleted -/// or all ref counts are decreased -void SfxPoolItemArray_Impl::clear() -{ - maPoolItemSet.clear(); - maSortablePoolItems.clear(); -} - -sal_uInt16 SfxItemPool::GetFirstWhich() const -{ - return pImpl->mnStart; -} - -sal_uInt16 SfxItemPool::GetLastWhich() const -{ - return pImpl->mnEnd; -} - -bool SfxItemPool::IsInRange( sal_uInt16 nWhich ) const -{ - return nWhich >= pImpl->mnStart && nWhich <= pImpl->mnEnd; -} - -sal_uInt16 SfxItemPool::GetIndex_Impl(sal_uInt16 nWhich) const -{ - if (nWhich < pImpl->mnStart || nWhich > pImpl->mnEnd) - { - assert(false && "missing bounds check before use"); - return 0; - } - return nWhich - pImpl->mnStart; -} - -sal_uInt16 SfxItemPool::GetSize_Impl() const -{ - return pImpl->mnEnd - pImpl->mnStart + 1; -} - - -bool SfxItemPool::CheckItemInPool(const SfxPoolItem *pItem) const -{ - DBG_ASSERT( pItem, "no 0-Pointer Surrogate" ); - DBG_ASSERT( !IsInvalidItem(pItem), "no Invalid-Item Surrogate" ); - DBG_ASSERT( !IsPoolDefaultItem(pItem), "no Pool-Default-Item Surrogate" ); - - if ( !IsInRange(pItem->Which()) ) - { - if ( pImpl->mpSecondary ) - return pImpl->mpSecondary->CheckItemInPool( pItem ); - SAL_WARN( "svl.items", "unknown Which-Id - don't ask me for surrogates, with ID/pos " << pItem->Which()); - } - - // Pointer on static or pool-default attribute? - if( IsStaticDefaultItem(pItem) || IsPoolDefaultItem(pItem) ) - return true; - - SfxPoolItemArray_Impl& rItemArr = pImpl->maPoolItemArrays[GetIndex_Impl(pItem->Which())]; - - for ( auto p : rItemArr ) - { - if ( p == pItem ) - return true; - } - SAL_WARN( "svl.items", "Item not in the pool, with ID/pos " << pItem->Which()); - return false; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit