Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
5a7eae70
Commit
5a7eae70
authored
Dec 28, 2013
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed slice appending for integers
parent
d6460f3d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
rlp.go
rlp.go
+2
-2
rlp_test.go
rlp_test.go
+7
-1
No files found.
rlp.go
View file @
5a7eae70
...
...
@@ -45,7 +45,7 @@ func Decode(data []byte, pos int) (interface{}, int) {
slice
:=
make
([]
interface
{},
0
)
switch
{
case
char
<
24
:
return
append
(
slice
,
data
[
pos
])
,
pos
+
1
return
data
[
pos
]
,
pos
+
1
case
char
<
56
:
b
:=
int
(
data
[
pos
])
-
23
return
FromBin
(
data
[
pos
+
1
:
pos
+
1
+
b
]),
pos
+
1
+
b
...
...
@@ -72,7 +72,7 @@ func Decode(data []byte, pos int) (interface{}, int) {
return
slice
,
pos
case
char
<
192
:
b
:=
int
(
data
[
pos
])
-
183
//b2 := int(FromBin(data[pos+1 : pos+1+b])) (ref imp
r
ementation has an unused variable)
//b2 := int(FromBin(data[pos+1 : pos+1+b])) (ref imp
l
ementation has an unused variable)
pos
=
pos
+
1
+
b
for
i
:=
0
;
i
<
b
;
i
++
{
var
obj
interface
{}
...
...
rlp_test.go
View file @
5a7eae70
...
...
@@ -15,7 +15,6 @@ func TestEncode(t *testing.T) {
dec
,
_
:=
Decode
(
bytes
,
0
)
fmt
.
Printf
(
"raw: %v encoded: %q == %v
\n
"
,
dec
,
str
,
"dog"
)
sliceRes
:=
"
\x83
CdogCgodCcat"
strs
:=
[]
string
{
"dog"
,
"god"
,
"cat"
}
bytes
=
Encode
(
strs
)
...
...
@@ -27,3 +26,10 @@ func TestEncode(t *testing.T) {
dec
,
_
=
Decode
(
bytes
,
0
)
fmt
.
Printf
(
"raw: %v encoded: %q == %v
\n
"
,
dec
,
slice
,
strs
)
}
func
BenchmarkEncodeDecode
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
bytes
:=
Encode
([]
string
{
"dog"
,
"god"
,
"cat"
})
Decode
(
bytes
,
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