Skip to content

Commit

Permalink
Same BS refcounting for hashes as for arrays, also using LinkedHashMa…
Browse files Browse the repository at this point in the history
…p so we retain the order of the hash (+some formatting)
  • Loading branch information
niven committed Sep 24, 2012
1 parent 31266a6 commit e67b115
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 99 deletions.
7 changes: 4 additions & 3 deletions Java/src/com/booking/sereal/Decoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.nio.ByteOrder;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -270,7 +271,7 @@ private Map<String, Object> read_hash(byte tag) throws SerealException {
num_keys = tag & 15;
}

Map<String, Object> hash = new HashMap<String, Object>( (int) num_keys );
Map<String, Object> hash = new LinkedHashMap<String, Object>( (int) num_keys );

log.fine( "Reading " + num_keys + " hash elements" );

Expand Down Expand Up @@ -481,7 +482,7 @@ Object readSingleValue() throws SerealException {


/**
* Read a short binary ASCII string, the lower bits of the tag hold the length
* Read a short binary ISO-8859-1 (latin1) string, the lower bits of the tag hold the length
* @param tag
* @return
*/
Expand All @@ -490,7 +491,7 @@ String read_short_binary(byte tag) {
log.fine( "Short binary, length: " + length );
byte[] buf = new byte[length];
data.get( buf );
return Charset.forName( "US-ASCII" ).decode( ByteBuffer.wrap( buf ) ).toString();
return Charset.forName( "ISO-8859-1" ).decode( ByteBuffer.wrap( buf ) ).toString();
}

/**
Expand Down
Loading

0 comments on commit e67b115

Please sign in to comment.