def SignedVarintEncode(value):
  result = ""
  if value < 0:
    value += (1 << 64)

  bits = value & 0x7f
  value >>= 7
  while value:
    result += HIGH_CHR_MAP[bits]
    bits = value & 0x7f
    value >>= 7
  result += CHR_MAP[bits]

  return result


# This function is HOT.
Encode a signed integer as a zigzag encoded signed integer.
dataset/ETHPy150Open google/grr/grr/lib/rdfvalues/structs.py/SignedVarintEncode