sc/inc/address.hxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
New commits: commit 1d030e2a12d50ba9a0eb5b74219ba6cb14715ce0 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Apr 5 15:48:29 2019 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Fri Apr 5 23:25:32 2019 +0200 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 <er...@redhat.com> 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 ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits