in reply to Re: Architectural question...
in thread Architectural question...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Architectural question...
by BrowserUk (Patriarch) on Jul 05, 2005 at 10:58 UTC | |
I don't get this code? You take the keys in turn and break them into their constituant parts.
Then you iterate over those parts and concatenate them back together, piece by piece, into $id.
And then, if $id (so far) doesn't match $key, you skip to the next iteration
Which means you'll never reach this code, until you've completely re-built $id to match $key.
Which, unless I'm missing something (quite possible), there is no need for split or the for loop as this would do the same thing:
What did I miss? BTW. It won't help much towards your performance goal, but you can save a bit of memory by changing:
to
which does the same thing without copying all the keys to an array or sorting one set of them for no reason. Actually, if your low on memory, avoiding that sort and the (re-)allocation of those arrays might help your performance. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
| [reply] [d/l] [select] |
by devnul (Monk) on Jul 05, 2005 at 17:50 UTC | |
.. builds a hash where the key is something like "a.b.c.d". .. The problem is the total for a.b.c needs to be a sum of all the categories beneath it a.b.c.* and thus the top level category is the sum of "a.*". This "summation" is handled by the next snippet:
In the example where $key = 'a.b.c.d' each loop of the foreach loop would look something like:
I hope this clarifies! - dEvNuL | [reply] [d/l] [select] |