summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-04-13 20:42:16 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-04-14 12:34:35 +0200
commit7f2283c2986ff94766cc1d2c076fb34a2c88a31a (patch)
treeb4b8ef6fb02c5c78155db38ee878469c73bc9e26 /svl
parent30f9afa18d0b3726a5a38d9c2e35315f51f082a9 (diff)
Related: tdf#160056 1 entry is more common than no entries
Change-Id: I78fe8969120f894cf5c0a71fb61611af2d203d18 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166065 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/items/itemset.cxx18
1 files changed, 9 insertions, 9 deletions
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 3be339623ebc..5e361f8ad0b1 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -2292,11 +2292,8 @@ static void isMiss()
sal_uInt16 WhichRangesContainer::getOffsetFromWhich(sal_uInt16 nWhich) const
{
- if (empty())
- return INVALID_WHICHPAIR_OFFSET;
-
// special case for single entry - happens often e.g. UI stuff
- if (1 == m_size)
+ if (m_size == 1)
{
if( m_pairs->first <= nWhich && nWhich <= m_pairs->second )
return nWhich - m_pairs->first;
@@ -2305,6 +2302,9 @@ sal_uInt16 WhichRangesContainer::getOffsetFromWhich(sal_uInt16 nWhich) const
return INVALID_WHICHPAIR_OFFSET;
}
+ if (m_size == 0)
+ return INVALID_WHICHPAIR_OFFSET;
+
// check if nWhich is inside last successfully used WhichPair
if (INVALID_WHICHPAIR_OFFSET != m_aLastWhichPairOffset
&& m_aLastWhichPairFirst <= nWhich
@@ -2350,12 +2350,8 @@ sal_uInt16 WhichRangesContainer::getOffsetFromWhich(sal_uInt16 nWhich) const
sal_uInt16 WhichRangesContainer::getWhichFromOffset(sal_uInt16 nOffset) const
{
- // check for empty, if yes, return null which is an invalid WhichID
- if (empty())
- return 0;
-
// special case for single entry - happens often e.g. UI stuff
- if (1 == m_size)
+ if (m_size == 1)
{
if (nOffset <= m_pairs->second - m_pairs->first)
return m_pairs->first + nOffset;
@@ -2364,6 +2360,10 @@ sal_uInt16 WhichRangesContainer::getWhichFromOffset(sal_uInt16 nOffset) const
return 0;
}
+ // check for empty, if yes, return null which is an invalid WhichID
+ if (m_size == 0)
+ return 0;
+
// check if nWhich is inside last successfully used WhichPair
if (INVALID_WHICHPAIR_OFFSET != m_aLastWhichPairOffset)
{