Skip to content

Commit 253c1da

Browse files
committed
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.
1 parent 1ace6b2 commit 253c1da

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

prepared.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ type Prepared struct {
2222

2323
func fillPrepare(enc *msgpack.Encoder, expr string) error {
2424
enc.EncodeMapLen(1)
25-
enc.EncodeUint64(KeySQLText)
25+
enc.EncodeUint(KeySQLText)
2626
return enc.EncodeString(expr)
2727
}
2828

2929
func fillUnprepare(enc *msgpack.Encoder, stmt Prepared) error {
3030
enc.EncodeMapLen(1)
31-
enc.EncodeUint64(KeyStmtID)
32-
return enc.EncodeUint64(uint64(stmt.StatementID))
31+
enc.EncodeUint(KeyStmtID)
32+
return enc.EncodeUint(uint(stmt.StatementID))
3333
}
3434

3535
func fillExecutePrepared(enc *msgpack.Encoder, stmt Prepared, args interface{}) error {
3636
enc.EncodeMapLen(2)
37-
enc.EncodeUint64(KeyStmtID)
38-
enc.EncodeUint64(uint64(stmt.StatementID))
39-
enc.EncodeUint64(KeySQLBind)
37+
enc.EncodeUint(KeyStmtID)
38+
enc.EncodeUint(uint(stmt.StatementID))
39+
enc.EncodeUint(KeySQLBind)
4040
return encodeSQLBind(enc, args)
4141
}
4242

request.go

+25-25
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ import (
1111
)
1212

1313
func fillSearch(enc *msgpack.Encoder, spaceNo, indexNo uint32, key interface{}) error {
14-
enc.EncodeUint64(KeySpaceNo)
15-
enc.EncodeUint64(uint64(spaceNo))
16-
enc.EncodeUint64(KeyIndexNo)
17-
enc.EncodeUint64(uint64(indexNo))
18-
enc.EncodeUint64(KeyKey)
14+
enc.EncodeUint(KeySpaceNo)
15+
enc.EncodeUint(uint(spaceNo))
16+
enc.EncodeUint(KeyIndexNo)
17+
enc.EncodeUint(uint(indexNo))
18+
enc.EncodeUint(KeyKey)
1919
return enc.Encode(key)
2020
}
2121

2222
func fillIterator(enc *msgpack.Encoder, offset, limit, iterator uint32) {
23-
enc.EncodeUint64(KeyIterator)
24-
enc.EncodeUint64(uint64(iterator))
25-
enc.EncodeUint64(KeyOffset)
26-
enc.EncodeUint64(uint64(offset))
27-
enc.EncodeUint64(KeyLimit)
28-
enc.EncodeUint64(uint64(limit))
23+
enc.EncodeUint(KeyIterator)
24+
enc.EncodeUint(uint(iterator))
25+
enc.EncodeUint(KeyOffset)
26+
enc.EncodeUint(uint(offset))
27+
enc.EncodeUint(KeyLimit)
28+
enc.EncodeUint(uint(limit))
2929
}
3030

3131
func fillInsert(enc *msgpack.Encoder, spaceNo uint32, tuple interface{}) error {
3232
enc.EncodeMapLen(2)
33-
enc.EncodeUint64(KeySpaceNo)
34-
enc.EncodeUint64(uint64(spaceNo))
35-
enc.EncodeUint64(KeyTuple)
33+
enc.EncodeUint(KeySpaceNo)
34+
enc.EncodeUint(uint(spaceNo))
35+
enc.EncodeUint(KeyTuple)
3636
return enc.Encode(tuple)
3737
}
3838

@@ -47,19 +47,19 @@ func fillUpdate(enc *msgpack.Encoder, spaceNo, indexNo uint32, key, ops interfac
4747
if err := fillSearch(enc, spaceNo, indexNo, key); err != nil {
4848
return err
4949
}
50-
enc.EncodeUint64(KeyTuple)
50+
enc.EncodeUint(KeyTuple)
5151
return enc.Encode(ops)
5252
}
5353

5454
func fillUpsert(enc *msgpack.Encoder, spaceNo uint32, tuple, ops interface{}) error {
5555
enc.EncodeMapLen(3)
56-
enc.EncodeUint64(KeySpaceNo)
57-
enc.EncodeUint64(uint64(spaceNo))
58-
enc.EncodeUint64(KeyTuple)
56+
enc.EncodeUint(KeySpaceNo)
57+
enc.EncodeUint(uint(spaceNo))
58+
enc.EncodeUint(KeyTuple)
5959
if err := enc.Encode(tuple); err != nil {
6060
return err
6161
}
62-
enc.EncodeUint64(KeyDefTuple)
62+
enc.EncodeUint(KeyDefTuple)
6363
return enc.Encode(ops)
6464
}
6565

@@ -70,25 +70,25 @@ func fillDelete(enc *msgpack.Encoder, spaceNo, indexNo uint32, key interface{})
7070

7171
func fillCall(enc *msgpack.Encoder, functionName string, args interface{}) error {
7272
enc.EncodeMapLen(2)
73-
enc.EncodeUint64(KeyFunctionName)
73+
enc.EncodeUint(KeyFunctionName)
7474
enc.EncodeString(functionName)
75-
enc.EncodeUint64(KeyTuple)
75+
enc.EncodeUint(KeyTuple)
7676
return enc.Encode(args)
7777
}
7878

7979
func fillEval(enc *msgpack.Encoder, expr string, args interface{}) error {
8080
enc.EncodeMapLen(2)
81-
enc.EncodeUint64(KeyExpression)
81+
enc.EncodeUint(KeyExpression)
8282
enc.EncodeString(expr)
83-
enc.EncodeUint64(KeyTuple)
83+
enc.EncodeUint(KeyTuple)
8484
return enc.Encode(args)
8585
}
8686

8787
func fillExecute(enc *msgpack.Encoder, expr string, args interface{}) error {
8888
enc.EncodeMapLen(2)
89-
enc.EncodeUint64(KeySQLText)
89+
enc.EncodeUint(KeySQLText)
9090
enc.EncodeString(expr)
91-
enc.EncodeUint64(KeySQLBind)
91+
enc.EncodeUint(KeySQLBind)
9292
return encodeSQLBind(enc, args)
9393
}
9494

stream.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func fillBegin(enc *msgpack.Encoder, txnIsolation TxnIsolationLevel, timeout tim
4646
}
4747

4848
if hasTimeout {
49-
err = enc.EncodeUint64(KeyTimeout)
49+
err = enc.EncodeUint(KeyTimeout)
5050
if err != nil {
5151
return err
5252
}

0 commit comments

Comments
 (0)