gecko-dev/toolkit
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
..
components Bug 348627 O(N^2) or worse algorithm in error console 2006-08-14 22:03:34 +00:00
content Bug 343884 Column order was reset on restart r=enn sr=jag 2006-08-14 10:28:15 +00:00
library Bug 347884 Building XULRunner with --embedding-profile=minimal failed, tkhstory 2006-08-14 15:49:06 +00:00
locales string changes for bug #329729: 2006-08-11 17:54:59 +00:00
mozapps Bug 347954 - Running the NSIS installer as normal user (restricted group) or without enough free space available makes it silently fail. r=sspitzer, a1.8.1=beltzner 2006-08-14 18:04:17 +00:00
obsolete Bug 236613: change to MPL/LGPL/GPL tri-license. 2005-12-31 16:02:07 +00:00
profile Bug 307400. Scrolling profiles in Profile Manager broken in some localizations. r=mano 2006-08-06 05:32:42 +00:00
system (part of) bug 333640 link to all required libraries 2006-07-27 14:42:27 +00:00
themes Bug 345510, add XUL numberbox, r=neil,mano,sr=neil 2006-08-14 02:44:00 +00:00
xre Backout bug 345517 due to various issues. 2006-08-10 14:06:47 +00:00
.cvsignore
empty-file Bug 328678 - XULRunner should include about:plugins, r=neil@p 2006-08-07 16:06:03 +00:00
Makefile.in