Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Boxiang Sun
Pyston
Commits
b2f3653a
Commit
b2f3653a
authored
Apr 05, 2016
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small refcounting fixing in tuple
parent
fcf746df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+14
-8
No files found.
src/runtime/tuple.cpp
View file @
b2f3653a
...
@@ -32,8 +32,6 @@ extern "C" Box* createTuple(int64_t nelts, Box** elts) {
...
@@ -32,8 +32,6 @@ extern "C" Box* createTuple(int64_t nelts, Box** elts) {
}
}
Box
*
_tupleSlice
(
BoxedTuple
*
self
,
i64
start
,
i64
stop
,
i64
step
,
i64
length
)
{
Box
*
_tupleSlice
(
BoxedTuple
*
self
,
i64
start
,
i64
stop
,
i64
step
,
i64
length
)
{
assert
(
0
&&
"check refcounting"
);
i64
size
=
self
->
size
();
i64
size
=
self
->
size
();
assert
(
step
!=
0
);
assert
(
step
!=
0
);
if
(
step
>
0
)
{
if
(
step
>
0
)
{
...
@@ -118,23 +116,27 @@ extern "C" int _PyTuple_Resize(PyObject** pv, Py_ssize_t newsize) noexcept {
...
@@ -118,23 +116,27 @@ extern "C" int _PyTuple_Resize(PyObject** pv, Py_ssize_t newsize) noexcept {
}
}
int
BoxedTuple
::
Resize
(
BoxedTuple
**
pv
,
size_t
newsize
)
noexcept
{
int
BoxedTuple
::
Resize
(
BoxedTuple
**
pv
,
size_t
newsize
)
noexcept
{
assert
(
0
&&
"check refcounting"
);
assert
((
*
pv
)
->
cls
==
tuple_cls
);
assert
((
*
pv
)
->
cls
==
tuple_cls
);
BoxedTuple
*
t
=
static_cast
<
BoxedTuple
*>
(
*
pv
);
BoxedTuple
*
t
=
static_cast
<
BoxedTuple
*>
(
*
pv
);
size_t
oldsize
=
t
->
size
();
if
(
newsize
==
t
->
size
()
)
if
(
newsize
==
oldsize
)
return
0
;
return
0
;
if
(
newsize
<
t
->
size
()
)
{
if
(
newsize
<
oldsize
)
{
// XXX resize the box (by reallocating) smaller if it makes sense
// XXX resize the box (by reallocating) smaller if it makes sense
t
->
ob_size
=
newsize
;
t
->
ob_size
=
newsize
;
for
(
int
i
=
newsize
;
i
<
oldsize
;
i
++
)
{
Py_CLEAR
((
*
pv
)
->
elts
[
i
]);
}
return
0
;
return
0
;
}
}
BoxedTuple
*
resized
=
new
(
newsize
)
BoxedTuple
();
BoxedTuple
*
resized
=
new
(
newsize
)
BoxedTuple
();
memmove
(
resized
->
elts
,
t
->
elts
,
sizeof
(
Box
*
)
*
t
->
size
()
);
memmove
(
resized
->
elts
,
t
->
elts
,
sizeof
(
Box
*
)
*
oldsize
);
memset
(
resized
->
elts
+
t
->
size
(),
0
,
sizeof
(
Box
*
)
*
(
newsize
-
t
->
size
()
));
memset
(
resized
->
elts
+
oldsize
,
0
,
sizeof
(
Box
*
)
*
(
newsize
-
oldsize
));
*
pv
=
resized
;
*
pv
=
resized
;
return
0
;
return
0
;
...
@@ -179,7 +181,6 @@ Box* tupleAdd(BoxedTuple* self, Box* rhs) {
...
@@ -179,7 +181,6 @@ Box* tupleAdd(BoxedTuple* self, Box* rhs) {
}
}
Box
*
tupleMulInt
(
BoxedTuple
*
self
,
int
n
)
{
Box
*
tupleMulInt
(
BoxedTuple
*
self
,
int
n
)
{
assert
(
0
&&
"check refcounting"
);
int
s
=
self
->
size
();
int
s
=
self
->
size
();
if
(
n
<
0
)
if
(
n
<
0
)
...
@@ -190,10 +191,15 @@ Box* tupleMulInt(BoxedTuple* self, int n) {
...
@@ -190,10 +191,15 @@ Box* tupleMulInt(BoxedTuple* self, int n) {
}
else
{
}
else
{
BoxedTuple
*
rtn
=
BoxedTuple
::
create
(
n
*
s
);
BoxedTuple
*
rtn
=
BoxedTuple
::
create
(
n
*
s
);
int
rtn_i
=
0
;
int
rtn_i
=
0
;
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
memmove
(
&
rtn
->
elts
[
rtn_i
],
&
self
->
elts
[
0
],
sizeof
(
Box
*
)
*
s
);
memmove
(
&
rtn
->
elts
[
rtn_i
],
&
self
->
elts
[
0
],
sizeof
(
Box
*
)
*
s
);
rtn_i
+=
s
;
rtn_i
+=
s
;
}
}
for
(
int
i
=
0
;
i
<
rtn
->
size
();
i
++
)
Py_INCREF
(
rtn
->
elts
[
i
]);
return
rtn
;
return
rtn
;
}
}
}
}
...
...
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