int (CharIterator in) { int result = 0; int shift = 0; int digit; do { digit = Base64.BASE64_DECODE_MAP[in.next()]; assert (digit != -1) : "invalid char"; result += (digit & VLQ_BASE_MASK) << shift; shift += VLQ_BASE_SHIFT; } while ((digit & VLQ_CONTINUATION_BIT) != 0); boolean negate = (result & 1) == 1; result >>= 1; return negate ? -result : result; }