gecko-dev/xpfe/components
timeless%mozdev.org cd70f66472 Bug 348627 O(N^2) or worse algorithm in error console
r=bz sr=bz

Perhaps an explanation. String concatenation is a chance for garbage collection.
If you have unbounded input, this can be pretty bad. When you start running low
on memory, the garbage collector gets desperate and won't take shortcuts. Worst of
all, the original code generates one string of garbage every iteration starting with
the second or third.

This code uses a=[] to construct an array and a[n] to set the upper array boundary,
0 being the lower, and there are n slots between a[0] and a[n].
join() will build a string with n copies of the join argument, where n is the number                                                        of slots between between cells. So for:
a=[]; a[1]=''; there's 1 slot between [0] and [1]. The array's length is actually 2,
but the joined length will be 1.

While it is possible to use new Array(x), the behavior is different because the
array has length x and there are x-1 spaces between cells. This leads to code which
would be both much longer and harder to read. And definitely not particularly
intuitive.

The code used here otoh, while magical will hopefully require you to pause, think,
and quickly understand what's going on. If not, you paused long enough for this
bubble to appear and explain it to you :).
2006-08-14 22:03:34 +00:00
..
alerts
autocomplete Bug 255124 Keep favicon in URL bar from getting distorted when using larger fonts 2006-08-13 20:57:38 +00:00
bookmarks Seamonkey-only bustage from bug 347183 - I'm currently building a tree with this, but it should be right 2006-08-08 19:05:50 +00:00
build
console Bug 348627 O(N^2) or worse algorithm in error console 2006-08-14 22:03:34 +00:00
cookie/locale/en-US
directory Bug 347183 - frozen-linkage access to null/singleton/union/array enumerators, r=darin 2006-08-08 18:18:50 +00:00
download-manager Spelling fixup for bug 311098 from stephend plus sane punctuation. r=biesi 2006-08-06 01:46:21 +00:00
extensions
filepicker Filepicker needs accesskey for dirTextInputLabel. b=250177 r+sr=neil 2006-08-06 03:11:09 +00:00
find
history
intl
killAll
related Seamonkey-only bustage from bug 347183 - I'm currently building a tree with this, but it should be right 2006-08-08 19:05:50 +00:00
resetPref
search Seamonkey-only bustage from bug 347183 - I'm currently building a tree with this, but it should be right 2006-08-08 19:05:50 +00:00
sidebar
startup
updates
urlwidget
windowds
winhooks
xfer/resources/locale/en-US
xremote
.cvsignore
jar.mn
Makefile.in Bug 348381 Tidy up browser-prefs.js and console ifdefs. r=Benjamin,sr=Neil 2006-08-14 18:01:27 +00:00
nsXPFEComponentsCID.h