summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-04-05 15:48:29 +0200
committerEike Rathke <erack@redhat.com>2019-04-05 23:25:32 +0200
commit1d030e2a12d50ba9a0eb5b74219ba6cb14715ce0 (patch)
tree5346b5da7be92dd43bb39a9be43951e5346c6580 /sc
parent515d2579d305a6127c6c194319a58eac62437e33 (diff)
sc hash functions, use 64-bit range when available
Change-Id: If4d5b302343991122290ae64ec62b6f0bcfa97a3 Reviewed-on: https://gerrit.libreoffice.org/70305 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/address.hxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index e04e0d50f5d9..ea047866e1e3 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -460,6 +460,12 @@ inline bool ScAddress::lessThanByRow( const ScAddress& rAddress ) const
inline size_t ScAddress::hash() const
{
+#if SAL_TYPES_SIZEOFPOINTER == 8
+ // 16 bits for the columns, and 20 bits for the rows
+ return (static_cast<size_t>(nTab) << 36) ^
+ (static_cast<size_t>(nCol) << 20) ^
+ static_cast<size_t>(nRow);
+#else
// Assume that there are not that many addresses with row > 2^16 AND column
// > 2^8 AND sheet > 2^8 so we won't have too many collisions.
if (nRow <= 0xffff)
@@ -468,6 +474,7 @@ inline size_t ScAddress::hash() const
else
return (static_cast<size_t>(nTab) << 28) ^
(static_cast<size_t>(nCol) << 24) ^ static_cast<size_t>(nRow);
+#endif
}
struct ScAddressHashFunctor
@@ -736,6 +743,14 @@ inline bool ScRange::In( const ScRange& rRange ) const
inline size_t ScRange::hashArea() const
{
+#if SAL_TYPES_SIZEOFPOINTER == 8
+ // 12 bits for the columns and 20 bits for the rows
+ return
+ (static_cast<size_t>(aStart.Row()) << 44) ^
+ (static_cast<size_t>(aStart.Col()) << 32) ^
+ (static_cast<size_t>(aEnd.Col()) << 20) ^
+ static_cast<size_t>(aEnd.Row());
+#else
// Assume that there are not that many ranges with identical corners so we
// won't have too many collisions. Also assume that more lower row and
// column numbers are used so that there are not too many conflicts with
@@ -748,10 +763,18 @@ inline size_t ScRange::hashArea() const
(static_cast<size_t>(aStart.Col()) << 21) ^ // start column <= 2^5
(static_cast<size_t>(aEnd.Col()) << 15) ^ // end column <= 2^6
static_cast<size_t>(aEnd.Row()); // end row <= 2^15
+#endif
}
inline size_t ScRange::hashStartColumn() const
{
+#if SAL_TYPES_SIZEOFPOINTER == 8
+ // 20 bits for the rows
+ return
+ (static_cast<size_t>(aStart.Col()) << 40) ^
+ (static_cast<size_t>(aStart.Row()) << 20) ^
+ static_cast<size_t>(aEnd.Row());
+#else
// Assume that for the start row more lower row numbers are used so that
// there are not too many conflicts with the column hashed into the higher
// values.
@@ -759,6 +782,7 @@ inline size_t ScRange::hashStartColumn() const
(static_cast<size_t>(aStart.Col()) << 24) ^ // start column <= 2^8
(static_cast<size_t>(aStart.Row()) << 16) ^ // start row <= 2^8
static_cast<size_t>(aEnd.Row());
+#endif
}
inline bool ValidRange( const ScRange& rRange )