Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
1f551156
Commit
1f551156
authored
Dec 29, 2009
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove all references to gobType() from the decoder.
Fixes #470. R=rsc CC=golang-dev
https://golang.org/cl/183074
parent
2aefb8d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
src/pkg/gob/decode.go
src/pkg/gob/decode.go
+20
-14
No files found.
src/pkg/gob/decode.go
View file @
1f551156
...
...
@@ -540,7 +540,7 @@ func (dec *Decoder) decOpFor(wireId typeId, rt reflect.Type, name string) (decOp
case
*
reflect
.
ArrayType
:
name
=
"element of "
+
name
elemId
:=
wireId
.
gobType
()
.
(
*
arrayType
)
.
Elem
elemId
:=
dec
.
wireType
[
wireId
]
.
array
.
Elem
elemOp
,
elemIndir
,
err
:=
dec
.
decOpFor
(
elemId
,
t
.
Elem
(),
name
)
if
err
!=
nil
{
return
nil
,
0
,
err
...
...
@@ -573,28 +573,29 @@ func (dec *Decoder) decIgnoreOpFor(wireId typeId) (decOp, os.Error) {
op
,
ok
:=
decIgnoreOpMap
[
wireId
]
if
!
ok
{
// Special cases
switch
t
:=
wireId
.
gobType
()
.
(
type
)
{
case
*
sliceType
:
elemId
:=
wireId
.
gobType
()
.
(
*
sliceType
)
.
Elem
wire
:=
dec
.
wireType
[
wireId
]
switch
{
case
wire
.
array
!=
nil
:
elemId
:=
wire
.
array
.
Elem
elemOp
,
err
:=
dec
.
decIgnoreOpFor
(
elemId
)
if
err
!=
nil
{
return
nil
,
err
}
op
=
func
(
i
*
decInstr
,
state
*
decodeState
,
p
unsafe
.
Pointer
)
{
state
.
err
=
ignore
Slice
(
state
,
elemOp
)
state
.
err
=
ignore
Array
(
state
,
elemOp
,
wire
.
array
.
Len
)
}
case
*
arrayType
:
elemId
:=
wire
Id
.
gobType
()
.
(
*
arrayType
)
.
Elem
case
wire
.
slice
!=
nil
:
elemId
:=
wire
.
slice
.
Elem
elemOp
,
err
:=
dec
.
decIgnoreOpFor
(
elemId
)
if
err
!=
nil
{
return
nil
,
err
}
op
=
func
(
i
*
decInstr
,
state
*
decodeState
,
p
unsafe
.
Pointer
)
{
state
.
err
=
ignore
Array
(
state
,
elemOp
,
t
.
Len
)
state
.
err
=
ignore
Slice
(
state
,
elemOp
)
}
case
*
structType
:
case
wire
.
strct
!=
nil
:
// Generate a closure that calls out to the engine for the nested type.
enginePtr
,
err
:=
dec
.
getIgnoreEnginePtr
(
wireId
)
if
err
!=
nil
{
...
...
@@ -660,8 +661,12 @@ func (dec *Decoder) compatibleType(fr reflect.Type, fw typeId) bool {
case
*
reflect
.
StringType
:
return
fw
==
tString
case
*
reflect
.
ArrayType
:
aw
,
ok
:=
fw
.
gobType
()
.
(
*
arrayType
)
return
ok
&&
t
.
Len
()
==
aw
.
Len
&&
dec
.
compatibleType
(
t
.
Elem
(),
aw
.
Elem
)
wire
,
ok
:=
dec
.
wireType
[
fw
]
if
!
ok
||
wire
.
array
==
nil
{
return
false
}
array
:=
wire
.
array
return
ok
&&
t
.
Len
()
==
array
.
Len
&&
dec
.
compatibleType
(
t
.
Elem
(),
array
.
Elem
)
case
*
reflect
.
SliceType
:
// Is it an array of bytes?
et
:=
t
.
Elem
()
...
...
@@ -714,8 +719,9 @@ func (dec *Decoder) compileDec(remoteId typeId, rt reflect.Type) (engine *decEng
continue
}
if
!
dec
.
compatibleType
(
localField
.
Type
,
wireField
.
id
)
{
details
:=
" ("
+
wireField
.
id
.
string
()
+
" incompatible with "
+
localField
.
Type
.
String
()
+
") in type "
+
remoteId
.
Name
()
return
nil
,
os
.
ErrorString
(
"gob: wrong type for field "
+
wireField
.
name
+
details
)
return
nil
,
os
.
ErrorString
(
"gob: wrong type ("
+
localField
.
Type
.
String
()
+
") for received field "
+
wireStruct
.
name
+
"."
+
wireField
.
name
)
}
op
,
indir
,
err
:=
dec
.
decOpFor
(
wireField
.
id
,
localField
.
Type
,
localField
.
Name
)
if
err
!=
nil
{
...
...
@@ -776,7 +782,7 @@ func (dec *Decoder) decode(wireId typeId, e interface{}) os.Error {
return
err
}
engine
:=
*
enginePtr
if
engine
.
numInstr
==
0
&&
st
.
NumField
()
>
0
&&
len
(
wireId
.
gobType
()
.
(
*
structType
)
.
field
)
>
0
{
if
engine
.
numInstr
==
0
&&
st
.
NumField
()
>
0
&&
len
(
dec
.
wireType
[
wireId
]
.
strct
.
field
)
>
0
{
name
:=
rt
.
Name
()
return
os
.
ErrorString
(
"gob: type mismatch: no fields matched compiling decoder for "
+
name
)
}
...
...
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