>>>I don't think it's assigning the string that's slow. It's calling
sendAndLoad that is slow, because I think when you make the call the data is
urlencoded or something

Yes, you're probably right. I thought maybe the string was encoded as soon
as it assigned, but it makes more sense that the encoding is done when the
data is actually sent.

If you're code already works, great, go with it. I was just suggesting
another approach, but I understand what you mean. You've invested
a considerable time on it and already works pretty good for your actual
needs, so it makes no sense to try another method that could be worse
performance-wise.

I've taken a glimpse at your code, by the way. I like that it's simple and
neat, but I was thinking that maybe you could avoid the first loop, by just
adding an else to the main if in the second loop. Not sure if it'll make a
noticeable difference in performance, since assigning an empty string to an
array element is fast, but you'll be saving almost 100.000 iterations (on a
320 x 300 image).

Something like this:

  comp[0] = orig[0];
  var lastEqualIndex = 0;
  for(var i = 1; i < l; i++){
    if(orig[i] != comp[lastEqualIndex]){
      //new color
      comp[i] = orig[i];
      lastEqualIndex = i;
    } else {
      comp[i] = "";
    }
  }
  return comp;
}

All in all, it's a good and simple solution!

Cheers
Juan Pablo Califano

2008/2/5, Dave Mennenoh <[EMAIL PROTECTED]>:
>
> Hi Juan - I don't think it's assigning the string that's slow. It's
> calling
> sendAndLoad that is slow, because I think when you make the call the data
> is
> urlencoded or something. I've already found that, and am not calling it. I
> was simply outputting the before and after string lengths to see how
> Base64
> and LZW worked. Could be the class I was using, but either way it was way
> too slow to be useful to me. My simple array compressor is nearly instant
> and on some images it's getting me an 80%+ reduction in the array size,
> which is more than enough for my needs. On average it's only around a 20%
> or
> so reduction, but that's still good enough as my images are not very big.
> I think you're idea is great, and for AS3 a definite, but in AS2 I fear
> it's
> just going to be too slow. Plus, I've already spent far too long on this
> little aside and should be moving on, though I do enjoy these kinds of
> things. If you want to see some of my test results, I posted a little
> article on my blog: www.dmennenoh.blogspot.com
>
> Thanks much!
>
>
> Dave -
> Head Developer
> http://www.blurredistinction.com
> Adobe Community Expert
> http://www.adobe.com/communities/experts/
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to