(s string)
| 227 | } |
| 228 | |
| 229 | func (enc *Encoder) tryWriteIntString(s string) (bool, error) { |
| 230 | intVal, ok := isEncodableUint32(s) |
| 231 | if !ok { |
| 232 | return false, nil |
| 233 | } |
| 234 | var err error |
| 235 | if intVal >= math.MinInt8 && intVal <= math.MaxInt8 { |
| 236 | err = enc.write([]byte{encodeInt8Prefix, byte(int8(intVal))}) |
| 237 | } else if intVal >= math.MinInt16 && intVal <= math.MaxInt16 { |
| 238 | buf := enc.buffer[0:3] |
| 239 | buf[0] = encodeInt16Prefix |
| 240 | binary.LittleEndian.PutUint16(buf[1:], uint16(int16(intVal))) |
| 241 | err = enc.write(buf) |
| 242 | } else if intVal >= math.MinInt32 && intVal <= math.MaxInt32 { |
| 243 | buf := enc.buffer[0:5] |
| 244 | buf[0] = encodeInt32Prefix |
| 245 | binary.LittleEndian.PutUint32(buf[1:], uint32(int32(intVal))) |
| 246 | err = enc.write(buf) |
| 247 | } else { |
| 248 | // beyond int32 range, but within int64 range |
| 249 | return false, nil |
| 250 | } |
| 251 | if err != nil { |
| 252 | return true, err |
| 253 | } |
| 254 | return true, nil |
| 255 | } |
| 256 | |
| 257 | func (enc *Encoder) writeLZFString(s string) error { |
| 258 | out, err := lzf.Compress([]byte(s)) |
no test coverage detected