blambo / wave-protocol

Automatically exported from code.google.com/p/wave-protocol
0 stars 0 forks source link

Hashes should be strings, not byte arrays, for platform portability. #244

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

The hash part of hashed versions is currently modelled as a byte array.  
However, the dominant platforms for wave tech are JVMs and JS engines, and byte 
arrays are only supported by one of them, which is a problem.

Neither the byte-ness not the array-ness of hashes is ever used: they are just 
blobs of data that get compared with other hashes.  A plain string is a more 
platform-portable data type for something that needs to perform that function.  
I'm not sure how GWT emulates byte arrays in JS, but I'd be fairly confident 
that using strings would result in less code, and more efficient code.

Note that when serializing to/from JSON, we are executing code to translate 
those byte arrays to/from strings anyway, which would be unnecessary if hashes 
were just strings.

Original issue reported on code.google.com by hearn...@google.com on 17 Mar 2011 at 12:27

GoogleCodeExporter commented 8 years ago
The obvious concern is the increased size of strings over byte arrays for a 
given amount of hash information, and IIRC this was the original reason for 
deciding with byte arrays.

However, I don't disagree.

Original comment by ano...@google.com on 26 Mar 2011 at 3:43