(
WriteContext context,
MetaString value,
IReadOnlyList<MetaStringEncoding> encodings,
MetaStringEncoder encoder)
| 1559 | } |
| 1560 | |
| 1561 | private static void WriteMetaString( |
| 1562 | WriteContext context, |
| 1563 | MetaString value, |
| 1564 | IReadOnlyList<MetaStringEncoding> encodings, |
| 1565 | MetaStringEncoder encoder) |
| 1566 | { |
| 1567 | MetaString normalized = encodings.Contains(value.Encoding) |
| 1568 | ? value |
| 1569 | : encoder.Encode(value.Value, encodings); |
| 1570 | if (!encodings.Contains(normalized.Encoding)) |
| 1571 | { |
| 1572 | throw new EncodingException("failed to normalize meta string encoding"); |
| 1573 | } |
| 1574 | |
| 1575 | byte[] bytes = normalized.Bytes; |
| 1576 | (uint index, bool isNew) = context.AssignMetaStringIndexIfAbsent(normalized); |
| 1577 | if (isNew) |
| 1578 | { |
| 1579 | context.Writer.WriteVarUInt32((uint)(bytes.Length << 1)); |
| 1580 | if (bytes.Length > 16) |
| 1581 | { |
| 1582 | context.Writer.WriteInt64(unchecked((long)MetaStringHash(normalized))); |
| 1583 | } |
| 1584 | else if (bytes.Length > 0) |
| 1585 | { |
| 1586 | context.Writer.WriteUInt8((byte)normalized.Encoding); |
| 1587 | } |
| 1588 | |
| 1589 | context.Writer.WriteBytes(bytes); |
| 1590 | } |
| 1591 | else |
| 1592 | { |
| 1593 | context.Writer.WriteVarUInt32(((index + 1) << 1) | 1); |
| 1594 | } |
| 1595 | } |
| 1596 | |
| 1597 | private static MetaString ReadMetaString( |
| 1598 | ReadContext context, |
nothing calls this directly
no test coverage detected