Export to GitHub

wave-protocol - issue #244

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


Posted on Mar 17, 2011 by Helpful Hippo

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.

Comment #1

Posted on Mar 26, 2011 by Massive Bear

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.

Status: New

Labels:
Type-Defect Priority-Medium