[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <50197348.9010101@gmail.com>
Date: Wed, 01 Aug 2012 20:19:52 +0200
From: Sasha Levin <levinsasha928@...il.com>
To: Tejun Heo <tj@...nel.org>
CC: torvalds@...ux-foundation.org, akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
paul.gortmaker@...driver.com
Subject: Re: [RFC 1/4] hashtable: introduce a small and naive hashtable
On 07/31/2012 08:23 PM, Tejun Heo wrote:
> Hello, Sasha.
>
> On Tue, Jul 31, 2012 at 08:05:17PM +0200, Sasha Levin wrote:
>> +#define HASH_INIT(name) \
>> +({ \
>> + int __i; \
>> + for (__i = 0 ; __i < HASH_SIZE(name) ; __i++) \
>> + INIT_HLIST_HEAD(&name[__i]); \
>> +})
>
> Why use macro?
>
>> +#define HASH_ADD(name, obj, key) \
>> + hlist_add_head(obj, &name[ \
>> + hash_long((unsigned long)key, HASH_BITS(name))]);
>
> Ditto.
Oh, yes, I've started working on this and remembered why it's macro in the first place.
Notice that we don't store hashtable size anywhere, this is because we can get it directly from the size of the hashtable array itself.
If we switch to using functions, we could no longer hide it anywhere (we'd need to either turn the buckets into a struct, or have the user pass it around to all functions).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists