(data string)
| 133 | } |
| 134 | |
| 135 | func (w *binaryEncoder) writeString(data string) { |
| 136 | var dictIndex byte |
| 137 | if tokenIndex, ok := token.IndexOfSingleToken(data); ok { |
| 138 | w.pushByte(tokenIndex) |
| 139 | } else if dictIndex, tokenIndex, ok = token.IndexOfDoubleByteToken(data); ok { |
| 140 | w.pushByte(token.Dictionary0 + dictIndex) |
| 141 | w.pushByte(tokenIndex) |
| 142 | } else if validateNibble(data) { |
| 143 | w.writePackedBytes(data, token.Nibble8) |
| 144 | } else if validateHex(data) { |
| 145 | w.writePackedBytes(data, token.Hex8) |
| 146 | } else { |
| 147 | w.writeStringRaw(data) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | func (w *binaryEncoder) writeBytes(value []byte) { |
| 152 | w.writeByteLength(len(value)) |
no test coverage detected