bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q: what is a fast way to see if an 'item' is present in an array?


From: Linda Walsh
Subject: Re: Q: what is a fast way to see if an 'item' is present in an array?
Date: Tue, 16 Feb 2016 19:26:06 -0800
User-agent: Thunderbird



Greg Wooledge wrote:
On Mon, Feb 15, 2016 at 07:59:21PM -0800, Linda Walsh wrote:
Obviously, If I could precook the array into
a hash, I'd think it would be faster... but
the "cooking part", I think, is the high
overhead part.

Redesign the entire script so that you use the associative array (hash)
from the beginning instead of, or in addition to, storing your information
in a "list" (indexed array).
It would also take throwing away previous cfg-file compat as well
as changing the linux kernel interface.  Somehow I don't think that
is going to be easier:

 (cd /sys/class/net/br0/brif/; echo *)
eth0 eth5
 grep  ^BRIDGE_PORTS "$CFG"
BRIDGE_PORTS='eth0 eth5'

---
In my case it's only 2, but other interfaces... still not that long
*usually*,
 (cd $PWD/holders; echo *)
dm-0 dm-1 dm-12 dm-2 dm-3 dm-4 dm-5 dm-6 dm-7 dm-8 dm-9
----
But I tend to think about worst case behaviors and at least
try to ask around if anyone has anything better... but in this case,
the impact is minimal.

Though when designing 'anew', I try to make things data/table
driven as much as possible for things that fit into that paradigm.

Thanks!
L.












reply via email to

[Prev in Thread] Current Thread [Next in Thread]