[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120926143126.GA22699@Krystal>
Date: Wed, 26 Sep 2012 10:31:27 -0400
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: David Laight <David.Laight@...LAB.COM>
Cc: Sasha Levin <levinsasha928@...il.com>,
torvalds@...ux-foundation.org, tj@...nel.org,
akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
rostedt@...dmis.org, ebiederm@...ssion.com, neilb@...e.de,
bfields@...ldses.org, ejt@...hat.com, snitzer@...hat.com,
edumazet@...gle.com, josh@...htriplett.org, rmallon@...il.com,
palves@...hat.com
Subject: Re: [PATCH v6] hashtable: introduce a small and naive hashtable
* David Laight (David.Laight@...LAB.COM) wrote:
> Amazing how something simple gets lots of comments and versions :-)
>
> > ...
> > + * This has to be a macro since HASH_BITS() will not work on pointers since
> > + * it calculates the size during preprocessing.
> > + */
> > +#define hash_empty(hashtable) \
> > +({ \
> > + int __i; \
> > + bool __ret = true; \
> > + \
> > + for (__i = 0; __i < HASH_SIZE(hashtable); __i++) \
> > + if (!hlist_empty(&hashtable[__i])) \
> > + __ret = false; \
> > + \
> > + __ret; \
> > +})
>
> Actually you could have a #define that calls a function
> passing in the address and size.
> Also, should the loop have a 'break' in it?
+1 Removing unnecessary variables defined within a
statement-expression is indeed something we want, and your suggestion of
a macro calling a static inline is, IMHO, spot-on.
The same should be done for hash_init().
And yes, a break would be welcome in that loop: no need to continue if
we encounter a non-empty hlist.
Thanks,
Mathieu
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
--
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