Changeset 5ae8168 in mainline


Ignore:
Timestamp:
2018-07-05T21:41:21Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b9076db
Parents:
e912cdf
git-author:
Dzejrou <dzejrou@…> (2018-04-25 17:38:07)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:21)
Message:

cpp: changed hash to be identity for integral and fp values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/impl/functional.hpp

    re912cdf r5ae8168  
    727727        T hash_(uint64_t x) noexcept
    728728        {
    729             // TODO: This is copied form adt/hash (temporarily),
    730             //       check if we can use something better.
    731             x = (x ^ 61) ^ (x >> 16);
    732             x = x + (x << 3);
    733             x = x ^ (x >> 4);
    734             x = x * 0x27d4eb2d;
    735             x = x ^ (x >> 15);
    736 
    737             return static_cast<T>((x << 32) | (x >> 32));
     729            /**
     730             * Note: std::hash is used for indexing in
     731             *       unordered containers, not for cryptography.
     732             *       Because of this, we decided to simply convert
     733             *       the value to uin64_t, which will help us
     734             *       with testing (since in order to create
     735             *       a collision in a multiset or multimap
     736             *       we simply need 2 values that congruent
     737             *       by the size of the table.
     738             */
     739            return static_cast<T>(x);
    738740        }
    739741
Note: See TracChangeset for help on using the changeset viewer.