From 3507ee30c335d597aeb65e9d8dcb85a3440195b9 Mon Sep 17 00:00:00 2001 From: Oleg Jukovec Date: Tue, 17 May 2022 11:06:12 +0300 Subject: [PATCH] code health: replace EncodeUint64 by EncodeUint We use everywhere EncodeInt instead of EncodeInt64. Also we use everywhere EncodeUint64 instead of EncodeUint. It can be confusing. Although EncodeUint64 and EncodeUint have same logic in msgpack.v2, but different in msgpack.v5. It's good for migration to msgpack.v5 too. Part of #124. --- prepared.go | 12 ++++++------ request.go | 50 +++++++++++++++++++++++++------------------------- stream.go | 2 +- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/prepared.go b/prepared.go index 0f9303344..2546d34b6 100644 --- a/prepared.go +++ b/prepared.go @@ -22,21 +22,21 @@ type Prepared struct { func fillPrepare(enc *msgpack.Encoder, expr string) error { enc.EncodeMapLen(1) - enc.EncodeUint64(KeySQLText) + enc.EncodeUint(KeySQLText) return enc.EncodeString(expr) } func fillUnprepare(enc *msgpack.Encoder, stmt Prepared) error { enc.EncodeMapLen(1) - enc.EncodeUint64(KeyStmtID) - return enc.EncodeUint64(uint64(stmt.StatementID)) + enc.EncodeUint(KeyStmtID) + return enc.EncodeUint(uint(stmt.StatementID)) } func fillExecutePrepared(enc *msgpack.Encoder, stmt Prepared, args interface{}) error { enc.EncodeMapLen(2) - enc.EncodeUint64(KeyStmtID) - enc.EncodeUint64(uint64(stmt.StatementID)) - enc.EncodeUint64(KeySQLBind) + enc.EncodeUint(KeyStmtID) + enc.EncodeUint(uint(stmt.StatementID)) + enc.EncodeUint(KeySQLBind) return encodeSQLBind(enc, args) } diff --git a/request.go b/request.go index a892ca678..7d14d3710 100644 --- a/request.go +++ b/request.go @@ -11,28 +11,28 @@ import ( ) func fillSearch(enc *msgpack.Encoder, spaceNo, indexNo uint32, key interface{}) error { - enc.EncodeUint64(KeySpaceNo) - enc.EncodeUint64(uint64(spaceNo)) - enc.EncodeUint64(KeyIndexNo) - enc.EncodeUint64(uint64(indexNo)) - enc.EncodeUint64(KeyKey) + enc.EncodeUint(KeySpaceNo) + enc.EncodeUint(uint(spaceNo)) + enc.EncodeUint(KeyIndexNo) + enc.EncodeUint(uint(indexNo)) + enc.EncodeUint(KeyKey) return enc.Encode(key) } func fillIterator(enc *msgpack.Encoder, offset, limit, iterator uint32) { - enc.EncodeUint64(KeyIterator) - enc.EncodeUint64(uint64(iterator)) - enc.EncodeUint64(KeyOffset) - enc.EncodeUint64(uint64(offset)) - enc.EncodeUint64(KeyLimit) - enc.EncodeUint64(uint64(limit)) + enc.EncodeUint(KeyIterator) + enc.EncodeUint(uint(iterator)) + enc.EncodeUint(KeyOffset) + enc.EncodeUint(uint(offset)) + enc.EncodeUint(KeyLimit) + enc.EncodeUint(uint(limit)) } func fillInsert(enc *msgpack.Encoder, spaceNo uint32, tuple interface{}) error { enc.EncodeMapLen(2) - enc.EncodeUint64(KeySpaceNo) - enc.EncodeUint64(uint64(spaceNo)) - enc.EncodeUint64(KeyTuple) + enc.EncodeUint(KeySpaceNo) + enc.EncodeUint(uint(spaceNo)) + enc.EncodeUint(KeyTuple) return enc.Encode(tuple) } @@ -47,19 +47,19 @@ func fillUpdate(enc *msgpack.Encoder, spaceNo, indexNo uint32, key, ops interfac if err := fillSearch(enc, spaceNo, indexNo, key); err != nil { return err } - enc.EncodeUint64(KeyTuple) + enc.EncodeUint(KeyTuple) return enc.Encode(ops) } func fillUpsert(enc *msgpack.Encoder, spaceNo uint32, tuple, ops interface{}) error { enc.EncodeMapLen(3) - enc.EncodeUint64(KeySpaceNo) - enc.EncodeUint64(uint64(spaceNo)) - enc.EncodeUint64(KeyTuple) + enc.EncodeUint(KeySpaceNo) + enc.EncodeUint(uint(spaceNo)) + enc.EncodeUint(KeyTuple) if err := enc.Encode(tuple); err != nil { return err } - enc.EncodeUint64(KeyDefTuple) + enc.EncodeUint(KeyDefTuple) return enc.Encode(ops) } @@ -70,25 +70,25 @@ func fillDelete(enc *msgpack.Encoder, spaceNo, indexNo uint32, key interface{}) func fillCall(enc *msgpack.Encoder, functionName string, args interface{}) error { enc.EncodeMapLen(2) - enc.EncodeUint64(KeyFunctionName) + enc.EncodeUint(KeyFunctionName) enc.EncodeString(functionName) - enc.EncodeUint64(KeyTuple) + enc.EncodeUint(KeyTuple) return enc.Encode(args) } func fillEval(enc *msgpack.Encoder, expr string, args interface{}) error { enc.EncodeMapLen(2) - enc.EncodeUint64(KeyExpression) + enc.EncodeUint(KeyExpression) enc.EncodeString(expr) - enc.EncodeUint64(KeyTuple) + enc.EncodeUint(KeyTuple) return enc.Encode(args) } func fillExecute(enc *msgpack.Encoder, expr string, args interface{}) error { enc.EncodeMapLen(2) - enc.EncodeUint64(KeySQLText) + enc.EncodeUint(KeySQLText) enc.EncodeString(expr) - enc.EncodeUint64(KeySQLBind) + enc.EncodeUint(KeySQLBind) return encodeSQLBind(enc, args) } diff --git a/stream.go b/stream.go index fdfe8408c..62ea0adf0 100644 --- a/stream.go +++ b/stream.go @@ -46,7 +46,7 @@ func fillBegin(enc *msgpack.Encoder, txnIsolation TxnIsolationLevel, timeout tim } if hasTimeout { - err = enc.EncodeUint64(KeyTimeout) + err = enc.EncodeUint(KeyTimeout) if err != nil { return err }