On Mar 11, 2006, at 11:00 AM, [EMAIL PROTECTED] wrote:
** Applied Peter's patch to ByteBuffer after some optimization.
I don't like this optimization.. seems premature.In my original patch, I first had it trying to auto-expand based on average bytes per character, then max bytes per character, and then giving up.. (and then, only calculating expected length if it was really needed, which could be argued is an optimization..)
In the tweak you committed, it is still possible for it to go into an infinite loop if we missed a case, and I feel far more comfortable knowing that the algorithm might be a tad slower and never have the possibility of going into an infinite loop.
The core of my concern is that the expectedLength is only based on the average bytes per character, which for UTF-8 is only 1.1. The max is 4, so its not that hard for the expected length to be way off if you have many wide characters.
-pete -- (peter.royal|osi)@pobox.com - http://fotap.org/~osi
smime.p7s
Description: S/MIME cryptographic signature
