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
3c69df82
Commit
3c69df82
authored
Apr 13, 2015
by
Travis Hance
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In `BoxedTuple`, remove `nelts`, and make `elts` an array rather than a pointer
parent
8b47368a
Changes
2
Show 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 @
3c69df82
...
@@ -128,7 +128,7 @@ int BoxedTuple::Resize(BoxedTuple** pv, size_t newsize) noexcept {
...
@@ -128,7 +128,7 @@ int BoxedTuple::Resize(BoxedTuple** pv, size_t newsize) noexcept {
if
(
newsize
<
t
->
size
())
{
if
(
newsize
<
t
->
size
())
{
// XXX resize the box (by reallocating) smaller if it makes sense
// XXX resize the box (by reallocating) smaller if it makes sense
t
->
nelts
=
newsize
;
t
->
ob_size
=
newsize
;
return
0
;
return
0
;
}
}
...
@@ -436,8 +436,8 @@ extern "C" void tupleIteratorGCHandler(GCVisitor* v, Box* b) {
...
@@ -436,8 +436,8 @@ extern "C" void tupleIteratorGCHandler(GCVisitor* v, Box* b) {
void
setupTuple
()
{
void
setupTuple
()
{
tuple_iterator_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
&
tupleIteratorGCHandler
,
0
,
0
,
sizeof
(
BoxedTuple
),
tuple_iterator_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
&
tupleIteratorGCHandler
,
0
,
0
,
false
,
"tuple"
);
sizeof
(
BoxedTupleIterator
),
false
,
"tuple"
);
tuple_cls
->
giveAttr
(
"__new__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
tupleNew
,
UNKNOWN
,
1
,
0
,
true
,
true
)));
tuple_cls
->
giveAttr
(
"__new__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
tupleNew
,
UNKNOWN
,
1
,
0
,
true
,
true
)));
CLFunction
*
getitem
=
createRTFunction
(
2
,
0
,
0
,
0
);
CLFunction
*
getitem
=
createRTFunction
(
2
,
0
,
0
,
0
);
...
...
src/runtime/types.h
View file @
3c69df82
...
@@ -551,8 +551,6 @@ class BoxedTuple : public BoxVar {
...
@@ -551,8 +551,6 @@ class BoxedTuple : public BoxVar {
public:
public:
typedef
std
::
vector
<
Box
*
,
StlCompatAllocator
<
Box
*>>
GCVector
;
typedef
std
::
vector
<
Box
*
,
StlCompatAllocator
<
Box
*>>
GCVector
;
Box
**
elts
;
DEFAULT_CLASS_VAR_SIMPLE
(
tuple_cls
,
sizeof
(
Box
*
));
DEFAULT_CLASS_VAR_SIMPLE
(
tuple_cls
,
sizeof
(
Box
*
));
static
BoxedTuple
*
create
(
int64_t
size
)
{
return
new
(
size
)
BoxedTuple
(
size
);
}
static
BoxedTuple
*
create
(
int64_t
size
)
{
return
new
(
size
)
BoxedTuple
(
size
);
}
...
@@ -593,27 +591,25 @@ public:
...
@@ -593,27 +591,25 @@ public:
static
int
Resize
(
BoxedTuple
**
pt
,
size_t
newsize
)
noexcept
;
static
int
Resize
(
BoxedTuple
**
pt
,
size_t
newsize
)
noexcept
;
Box
**
begin
()
const
{
return
&
elts
[
0
];
}
Box
*
const
*
begin
()
const
{
return
&
elts
[
0
];
}
Box
*
*
end
()
const
{
return
&
elts
[
nelts
];
}
Box
*
const
*
end
()
const
{
return
&
elts
[
ob_size
];
}
Box
*&
operator
[](
size_t
index
)
{
return
elts
[
index
];
}
Box
*&
operator
[](
size_t
index
)
{
return
elts
[
index
];
}
size_t
size
()
const
{
return
nelts
;
}
size_t
size
()
const
{
return
ob_size
;
}
private:
private:
size_t
nelts
;
BoxedTuple
(
size_t
size
)
{
memset
(
elts
,
0
,
sizeof
(
Box
*
)
*
size
);
}
BoxedTuple
(
size_t
size
)
:
elts
(
reinterpret_cast
<
Box
**>
((
char
*
)
this
+
tuple_cls
->
tp_basicsize
)),
nelts
(
size
)
{
memset
(
elts
,
0
,
sizeof
(
Box
*
)
*
size
);
}
BoxedTuple
(
std
::
initializer_list
<
Box
*>&
members
)
BoxedTuple
(
std
::
initializer_list
<
Box
*>&
members
)
{
:
elts
(
reinterpret_cast
<
Box
**>
((
char
*
)
this
+
tuple_cls
->
tp_basicsize
)),
nelts
(
members
.
size
())
{
// by the time we make it here elts[] is big enough to contain members
// by the time we make it here elts[] is big enough to contain members
Box
**
p
=
&
elts
[
0
];
Box
**
p
=
&
elts
[
0
];
for
(
auto
b
:
members
)
{
for
(
auto
b
:
members
)
{
*
p
++
=
b
;
*
p
++
=
b
;
}
}
}
}
public:
Box
*
elts
[
0
];
};
};
extern
"C"
BoxedTuple
*
EmptyTuple
;
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