Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
15ac6428
Commit
15ac6428
authored
Nov 24, 2013
by
Alexandre Vassalotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify save_bool in cpickle.
parent
aa33f239
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
18 deletions
+11
-18
Modules/_pickle.c
Modules/_pickle.c
+11
-18
No files found.
Modules/_pickle.c
View file @
15ac6428
...
...
@@ -110,16 +110,6 @@ enum opcode {
FRAME
=
'\x95'
};
/* These aren't opcodes -- they're ways to pickle bools before protocol 2
* so that unpicklers written before bools were introduced unpickle them
* as ints, but unpicklers after can recognize that bools were intended.
* Note that protocol 2 added direct ways to pickle bools.
*/
#undef TRUE
#define TRUE "I01\n"
#undef FALSE
#define FALSE "I00\n"
enum
{
/* Keep in synch with pickle.Pickler._BATCHSIZE. This is how many elements
batch_list/dict() pumps out before doing APPENDS/SETITEMS. Nothing will
...
...
@@ -1619,18 +1609,21 @@ save_none(PicklerObject *self, PyObject *obj)
static
int
save_bool
(
PicklerObject
*
self
,
PyObject
*
obj
)
{
static
const
char
*
buf
[
2
]
=
{
FALSE
,
TRUE
};
const
char
len
[
2
]
=
{
sizeof
(
FALSE
)
-
1
,
sizeof
(
TRUE
)
-
1
};
int
p
=
(
obj
==
Py_True
);
if
(
self
->
proto
>=
2
)
{
const
char
bool_op
=
p
?
NEWTRUE
:
NEWFALSE
;
const
char
bool_op
=
(
obj
==
Py_True
)
?
NEWTRUE
:
NEWFALSE
;
if
(
_Pickler_Write
(
self
,
&
bool_op
,
1
)
<
0
)
return
-
1
;
}
else
if
(
_Pickler_Write
(
self
,
buf
[
p
],
len
[
p
])
<
0
)
return
-
1
;
else
{
/* These aren't opcodes -- they're ways to pickle bools before protocol 2
* so that unpicklers written before bools were introduced unpickle them
* as ints, but unpicklers after can recognize that bools were intended.
* Note that protocol 2 added direct ways to pickle bools.
*/
const
char
*
bool_str
=
(
obj
==
Py_True
)
?
"I01
\n
"
:
"I00
\n
"
;
if
(
_Pickler_Write
(
self
,
bool_str
,
strlen
(
bool_str
))
<
0
)
return
-
1
;
}
return
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