On 11/30/05 10:05 PM, "Phil M" <phil at mobleybros dot com> wrote:
> On Nov 30, 2005, at 7:39 PM, Roph wrote:
>
>>> Actually you have to have the Little-Endian value defined because
>>> of the UShort. Besides giving a better distribution, it also runs
>>> almost twice as fast in REALbasic as grabbing each byte.
>>
>> Yes, processing the shorts is great. I wonder about the end-case
>> condition however in the event that the string has an odd number of
>> bytes and you map to the string in memory. I'd have to go stare
>> at it some more to be happy about that.
>
> I just added a byte to the string if it needed it. I used the "Ceil
> (s.Size / 2) * 2" to find the size that I needed
Yeah, this much I got.
> and then changed the
> size of the MemoryBlock (I cannot remember if this feature was
> introduced in REALbasic 2005):
>
> s.Size = kMax
>
And this does what? Presumably copies the entire string if the length of
the string is an odd number of bytes? If so that doesn't sound attractive.
>>> This was just a modified Adler-32 Checksum. I think the normal
>>> Adler-32 starts with a=1 and b=0 with an option parameter for a to
>>> take a different value. I just added the prime numbers for a and
>>> b to give short strings a kick-start.
>>
>> Sure. if you have the Adler32 algorithm or a pointer to it I'd
>> love to see it. If it's really just this simple, that might be a
>> fine algorithm to use, and there are already c-coded plugins for it
>> I believe.
>
> I took it from several different sources, and I think I ended up with
> one of the clearer (but not as optimized) versions of the algorithm.
> Here is I think the original algorithm:
>
> http://leithal.cool-tools.co.uk/sourcedoc/mysql509/html/
> adler32_8c-source.html
>
Very nice. Thanks for the enlightenment. Yes, I could certainly live very
happily with this, and as you say Bjorn already has it coded in a plugin --
though I doubt with the 16-bit chunk feature. On the other hand doing it a
byte at a time would indeed make it cross-platform compatible... If that
mattered.
Thanks!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|