Changeset 99bf4c4 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:
e037873d
Parents:
379ce989
git-author:
Dzejrou <dzejrou@…> (2018-04-25 21:31:27)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:21)
Message:

cpp: removed unnecessary key_extractor_ uses, rendunant increments that can be avoided with do/while instead of while, added keys_equal for constant context

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/internal/hash_table.hpp

    r379ce989 r99bf4c4  
    171171            do
    172172            {
    173                 if (table.key_eq_(key, table.key_extractor_(current->value)))
     173                if (table.keys_equal(key, current->value))
    174174                {
    175175                    --table.size_;
     
    200200            typename Table::iterator,
    201201            typename Table::iterator
    202         > equal_range(const Table& table, const Key& key)
     202        > equal_range(Table& table, const Key& key)
    203203        {
    204204            auto it = table.find(key);
     
    230230            do
    231231            {
    232                 if (table.key_eq_(key, table.key_extractor_(current->value)))
     232                if (table.keys_equal(key, current->value))
    233233                    ++res;
    234234
     
    251251                do
    252252                {
    253                     if (table.keys_equal(key, table.get_key(current->value)))
     253                    if (table.keys_equal(key, current->value))
    254254                    {
    255255                        return make_tuple(
     
    280280            while (it != table.end(it))
    281281            {
    282                 if (table.keys_equal(key, table.get_key(*it)))
     282                if (table.keys_equal(key, *it))
    283283                {
    284                     while (table.keys_equal(key, table.get_key(*it)))
     284                    while (table.keys_equal(key, *it))
    285285                    {
    286286                        auto node = it.node();
     
    307307            typename Table::iterator,
    308308            typename Table::iterator
    309         > equal_range(const Table& table, const Key& key)
     309        > equal_range(Table& table, const Key& key)
    310310        {
    311311            auto first = table.find(key);
     
    314314
    315315            auto last = first;
    316             while (table.keys_equal(key, table.get_key(*last)))
     316            do
     317            {
    317318                ++last;
    318 
    319             // The second iterator points one behind the range.
    320             ++last;
     319            } while (table.keys_equal(key, *last));
    321320
    322321            return make_pair(first, last);
     
    334333
    335334            auto last = first;
    336             while (table.keys_equal(key, table.get_key(*last)))
     335            do
     336            {
    337337                ++last;
    338 
    339             // The second iterator points one behind the range.
    340             ++last;
     338            } while (table.keys_equal(key, *last));
    341339
    342340            return make_pair(first, last);
     
    12171215            }
    12181216
     1217            bool keys_equal(const key_type& key, const value_type& val) const
     1218            {
     1219                return key_eq_(key, key_extractor_(val));
     1220            }
     1221
    12191222            hash_table_bucket<value_type, size_type>* table()
    12201223            {
Note: See TracChangeset for help on using the changeset viewer.