From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: Re: [tarantool-patches] Re: [PATCH 1/1] salad: fix mhash 'random' method References: <5f5c5a5994698deef183a31f46e8efaa9f4cd399.1551389056.git.v.shpilevoy@tarantool.org> <20190228220412.GC17469@chai> From: Vladislav Shpilevoy Message-ID: Date: Fri, 1 Mar 2019 12:40:43 +0300 MIME-Version: 1.0 In-Reply-To: <20190228220412.GC17469@chai> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit To: tarantool-patches@freelists.org, Konstantin Osipov Cc: vdavydov.dev@gmail.com List-ID: On 01/03/2019 01:04, Konstantin Osipov wrote: > * Vladislav Shpilevoy [19/03/01 00:29]: >> - return h->n_buckets; >> + mh_int_t res = mh_next(h, rnd % mh_end(h)); >> + if (res != mh_end(h)) >> + return res; >> + return mh_first(h); > > > Well, it takes some time to understand this code. IMO, it is much better to encapsulate those 'for' loops scanning for an occupied non-dirty slot, than put them into each function, working with buckets array. > > OK to push. Pushed to 2.1. > > > -- > Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 > http://tarantool.io - www.twitter.com/kostja_osipov >