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
d94c4ba8
Commit
d94c4ba8
authored
May 12, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #487 from tjhance/tuple-clean
Clean up the BoxedTuple class
parents
a230632b
3c69df82
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
15 deletions
+11
-15
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+3
-3
src/runtime/types.h
src/runtime/types.h
+8
-12
No files found.
src/runtime/tuple.cpp
View file @
d94c4ba8
...
...
@@ -128,7 +128,7 @@ int BoxedTuple::Resize(BoxedTuple** pv, size_t newsize) noexcept {
if
(
newsize
<
t
->
size
())
{
// XXX resize the box (by reallocating) smaller if it makes sense
t
->
nelts
=
newsize
;
t
->
ob_size
=
newsize
;
return
0
;
}
...
...
@@ -436,8 +436,8 @@ extern "C" void tupleIteratorGCHandler(GCVisitor* v, Box* b) {
void
setupTuple
()
{
tuple_iterator_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
&
tupleIteratorGCHandler
,
0
,
0
,
sizeof
(
BoxedTuple
),
false
,
"tuple"
);
tuple_iterator_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
&
tupleIteratorGCHandler
,
0
,
0
,
sizeof
(
BoxedTupleIterator
),
false
,
"tuple"
);
tuple_cls
->
giveAttr
(
"__new__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
tupleNew
,
UNKNOWN
,
1
,
0
,
true
,
true
)));
CLFunction
*
getitem
=
createRTFunction
(
2
,
0
,
0
,
0
);
...
...
src/runtime/types.h
View file @
d94c4ba8
...
...
@@ -550,8 +550,6 @@ class BoxedTuple : public BoxVar {
public:
typedef
std
::
vector
<
Box
*
,
StlCompatAllocator
<
Box
*>>
GCVector
;
Box
**
elts
;
DEFAULT_CLASS_VAR_SIMPLE
(
tuple_cls
,
sizeof
(
Box
*
));
static
BoxedTuple
*
create
(
int64_t
size
)
{
return
new
(
size
)
BoxedTuple
(
size
);
}
...
...
@@ -592,27 +590,25 @@ public:
static
int
Resize
(
BoxedTuple
**
pt
,
size_t
newsize
)
noexcept
;
Box
**
begin
()
const
{
return
&
elts
[
0
];
}
Box
*
*
end
()
const
{
return
&
elts
[
nelts
];
}
Box
*
const
*
begin
()
const
{
return
&
elts
[
0
];
}
Box
*
const
*
end
()
const
{
return
&
elts
[
ob_size
];
}
Box
*&
operator
[](
size_t
index
)
{
return
elts
[
index
];
}
size_t
size
()
const
{
return
nelts
;
}
size_t
size
()
const
{
return
ob_size
;
}
private:
size_t
nelts
;
BoxedTuple
(
size_t
size
)
:
elts
(
reinterpret_cast
<
Box
**>
((
char
*
)
this
+
tuple_cls
->
tp_basicsize
)),
nelts
(
size
)
{
memset
(
elts
,
0
,
sizeof
(
Box
*
)
*
size
);
}
BoxedTuple
(
size_t
size
)
{
memset
(
elts
,
0
,
sizeof
(
Box
*
)
*
size
);
}
BoxedTuple
(
std
::
initializer_list
<
Box
*>&
members
)
:
elts
(
reinterpret_cast
<
Box
**>
((
char
*
)
this
+
tuple_cls
->
tp_basicsize
)),
nelts
(
members
.
size
())
{
BoxedTuple
(
std
::
initializer_list
<
Box
*>&
members
)
{
// by the time we make it here elts[] is big enough to contain members
Box
**
p
=
&
elts
[
0
];
for
(
auto
b
:
members
)
{
*
p
++
=
b
;
}
}
public:
Box
*
elts
[
0
];
};
extern
"C"
BoxedTuple
*
EmptyTuple
;
...
...
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