Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
ce695ff1
Commit
ce695ff1
authored
Jan 20, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
dbfa81a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
22 deletions
+20
-22
t/neo/marshal.go
t/neo/marshal.go
+3
-12
t/neo/protogen.go
t/neo/protogen.go
+17
-10
No files found.
t/neo/marshal.go
View file @
ce695ff1
...
...
@@ -1007,10 +1007,7 @@ func (p *AnswerLockedTransactions) NEOEncodedLen() int {
l
:=
uint32
(
len
(
p
.
TidDict
))
_
=
l
size
+=
4
for
key
:=
range
p
.
TidDict
{
_
=
key
size
+=
16
}
size
+=
l
*
16
}
return
int
(
size
)
+
0
}
...
...
@@ -2758,10 +2755,7 @@ func (p *AnswerObjectUndoSerial) NEOEncodedLen() int {
l
:=
uint32
(
len
(
p
.
ObjectTIDDict
))
_
=
l
size
+=
4
for
key
:=
range
p
.
ObjectTIDDict
{
_
=
key
size
+=
25
}
size
+=
l
*
25
}
return
int
(
size
)
+
0
}
...
...
@@ -2966,10 +2960,7 @@ func (p *CheckReplicas) NEOEncodedLen() int {
l
:=
uint32
(
len
(
p
.
PartitionDict
))
_
=
l
size
+=
4
for
key
:=
range
p
.
PartitionDict
{
_
=
key
size
+=
8
}
size
+=
l
*
8
}
return
int
(
size
)
+
16
}
...
...
t/neo/protogen.go
View file @
ce695ff1
...
...
@@ -407,7 +407,8 @@ func (e *encoder) genMap(path string, typ *types.Map, obj types.Object) {
e
.
emit
(
"size += %v"
,
e
.
n
)
}
e
.
n
=
0
// TODO if size(item)==const - size update in one go
keySize
,
keyFixed
:=
typeSizeFixed
(
typ
.
Key
())
elemSize
,
elemFixed
:=
typeSizeFixed
(
typ
.
Elem
())
if
!
e
.
SizeOnly
{
// output keys in sorted order on the wire
// (easier for debugging & deterministic for testing)
...
...
@@ -418,17 +419,23 @@ func (e *encoder) genMap(path string, typ *types.Map, obj types.Object) {
e
.
emit
(
"sort.Slice(keyv, func (i, j int) bool { return keyv[i] < keyv[j] })"
)
e
.
emit
(
"for _, key := range keyv {"
)
}
else
{
e
.
emit
(
"for key := range %s {"
,
path
)
if
keyFixed
&&
elemFixed
{
e
.
emit
(
"size += l * %v"
,
keySize
+
elemSize
)
}
else
{
e
.
emit
(
"for key := range %s {"
,
path
)
}
}
codegenType
(
"key"
,
typ
.
Key
(),
obj
,
e
)
codegenType
(
fmt
.
Sprintf
(
"%s[key]"
,
path
),
typ
.
Elem
(),
obj
,
e
)
if
!
e
.
SizeOnly
{
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
// XXX wrt map of map?
}
else
{
e
.
emit
(
"_ = key"
)
// FIXME remove
e
.
emit
(
"size += %v"
,
e
.
n
)
if
!
(
e
.
SizeOnly
&&
keyFixed
&&
elemFixed
)
{
codegenType
(
"key"
,
typ
.
Key
(),
obj
,
e
)
codegenType
(
fmt
.
Sprintf
(
"%s[key]"
,
path
),
typ
.
Elem
(),
obj
,
e
)
if
!
e
.
SizeOnly
{
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
// XXX wrt map of map?
}
else
{
e
.
emit
(
"_ = key"
)
// FIXME remove
e
.
emit
(
"size += %v"
,
e
.
n
)
}
e
.
emit
(
"}"
)
}
e
.
emit
(
"}"
)
// XXX vvv ?
e
.
emit
(
"}"
)
e
.
n
=
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment