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
bf75c321
Commit
bf75c321
authored
Jun 01, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #517 from toshok/fewer-string-allocations
use llvm::StringRef instead of std::string typeNew
parents
c25abcd9
d5389981
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
14 deletions
+14
-14
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+11
-11
src/capi/typeobject.h
src/capi/typeobject.h
+1
-1
src/capi/types.h
src/capi/types.h
+2
-2
No files found.
src/capi/typeobject.cpp
View file @
bf75c321
...
...
@@ -1482,7 +1482,7 @@ static slotdef slotdefs[]
SQSLOT
(
"__contains__"
,
sq_contains
,
slot_sq_contains
,
wrap_objobjproc
,
"x.__contains__(y) <==> y in x"
),
SQSLOT
(
"__iadd__"
,
sq_inplace_concat
,
NULL
,
wrap_binaryfunc
,
"x.__iadd__(y) <==> x+=y"
),
SQSLOT
(
"__imul__"
,
sq_inplace_repeat
,
NULL
,
wrap_indexargfunc
,
"x.__imul__(y) <==> x*=y"
),
{
NULL
,
0
,
NULL
,
NULL
,
NULL
,
0
}
};
{
""
,
0
,
NULL
,
NULL
,
""
,
0
}
};
static
void
init_slotdefs
()
noexcept
{
static
bool
initialized
=
false
;
...
...
@@ -1491,21 +1491,21 @@ static void init_slotdefs() noexcept {
for
(
int
i
=
0
;
i
<
sizeof
(
slotdefs
)
/
sizeof
(
slotdefs
[
0
]);
i
++
)
{
if
(
i
>
0
)
{
if
(
!
slotdefs
[
i
].
name
)
if
(
!
slotdefs
[
i
].
name
.
size
()
)
continue
;
#ifndef NDEBUG
if
(
slotdefs
[
i
-
1
].
offset
>
slotdefs
[
i
].
offset
)
{
printf
(
"slotdef for %s in the wrong place
\n
"
,
slotdefs
[
i
-
1
].
name
);
printf
(
"slotdef for %s in the wrong place
\n
"
,
slotdefs
[
i
-
1
].
name
.
data
()
);
for
(
int
j
=
i
;
j
<
sizeof
(
slotdefs
)
/
sizeof
(
slotdefs
[
0
]);
j
++
)
{
if
(
slotdefs
[
i
-
1
].
offset
<=
slotdefs
[
j
].
offset
)
{
printf
(
"Should go before %s
\n
"
,
slotdefs
[
j
].
name
);
printf
(
"Should go before %s
\n
"
,
slotdefs
[
j
].
name
.
data
()
);
break
;
}
}
}
#endif
ASSERT
(
slotdefs
[
i
].
offset
>=
slotdefs
[
i
-
1
].
offset
,
"%d %s"
,
i
,
slotdefs
[
i
-
1
].
name
);
ASSERT
(
slotdefs
[
i
].
offset
>=
slotdefs
[
i
-
1
].
offset
,
"%d %s"
,
i
,
slotdefs
[
i
-
1
].
name
.
data
()
);
// CPython interns the name here
}
}
...
...
@@ -1534,7 +1534,7 @@ static void** resolve_slotdups(PyTypeObject* type, const std::string& name) noex
/* Collect all slotdefs that match name into ptrs. */
pname
=
name
;
pp
=
ptrs
;
for
(
p
=
slotdefs
;
p
->
name
;
p
++
)
{
for
(
p
=
slotdefs
;
p
->
name
.
size
()
!=
0
;
p
++
)
{
if
(
p
->
name
==
name
)
*
pp
++
=
p
;
}
...
...
@@ -1556,7 +1556,7 @@ static void** resolve_slotdups(PyTypeObject* type, const std::string& name) noex
}
static
const
slotdef
*
update_one_slot
(
BoxedClass
*
type
,
const
slotdef
*
p
)
noexcept
{
assert
(
p
->
name
);
assert
(
p
->
name
.
size
()
!=
0
);
PyObject
*
descr
;
BoxedWrapperDescriptor
*
d
;
...
...
@@ -1646,7 +1646,7 @@ static int update_slots_callback(PyTypeObject* type, void* data) noexcept {
static
int
update_subclasses
(
PyTypeObject
*
type
,
PyObject
*
name
,
update_callback
callback
,
void
*
data
)
noexcept
;
static
int
recurse_down_subclasses
(
PyTypeObject
*
type
,
PyObject
*
name
,
update_callback
callback
,
void
*
data
)
noexcept
;
bool
update_slot
(
BoxedClass
*
type
,
const
std
::
string
&
attr
)
noexcept
{
bool
update_slot
(
BoxedClass
*
type
,
llvm
::
StringRef
attr
)
noexcept
{
slotdef
*
ptrs
[
MAX_EQUIV
];
slotdef
*
p
;
slotdef
**
pp
;
...
...
@@ -1661,7 +1661,7 @@ bool update_slot(BoxedClass* type, const std::string& attr) noexcept {
init_slotdefs
();
pp
=
ptrs
;
for
(
p
=
slotdefs
;
p
->
name
;
p
++
)
{
for
(
p
=
slotdefs
;
p
->
name
.
size
()
!=
0
;
p
++
)
{
/* XXX assume name is interned! */
if
(
p
->
name
==
attr
)
*
pp
++
=
p
;
...
...
@@ -1688,7 +1688,7 @@ void fixup_slot_dispatchers(BoxedClass* self) noexcept {
init_slotdefs
();
const
slotdef
*
p
=
slotdefs
;
while
(
p
->
name
)
while
(
p
->
name
.
size
()
!=
0
)
p
=
update_one_slot
(
self
,
p
);
}
...
...
@@ -2666,7 +2666,7 @@ static void update_all_slots(PyTypeObject* type) noexcept {
slotdef
*
p
;
init_slotdefs
();
for
(
p
=
slotdefs
;
p
->
name
;
p
++
)
{
for
(
p
=
slotdefs
;
p
->
name
.
size
()
>
0
;
p
++
)
{
/* update_slot returns int but can't actually fail */
update_slot
(
type
,
p
->
name
);
}
...
...
src/capi/typeobject.h
View file @
bf75c321
...
...
@@ -20,7 +20,7 @@
namespace
pyston
{
// Returns if a slot was updated
bool
update_slot
(
BoxedClass
*
self
,
const
std
::
string
&
attr
)
noexcept
;
bool
update_slot
(
BoxedClass
*
self
,
llvm
::
StringRef
attr
)
noexcept
;
void
add_operators
(
BoxedClass
*
self
)
noexcept
;
void
fixup_slot_dispatchers
(
BoxedClass
*
self
)
noexcept
;
...
...
src/capi/types.h
View file @
bf75c321
...
...
@@ -25,11 +25,11 @@ typedef PyObject* (*wrapperfunc)(PyObject* self, PyObject* args, void* wrapped);
typedef
PyObject
*
(
*
wrapperfunc_kwds
)(
PyObject
*
self
,
PyObject
*
args
,
void
*
wrapped
,
PyObject
*
kwds
);
struct
wrapper_def
{
const
char
*
name
;
const
llvm
::
StringRef
name
;
int
offset
;
void
*
function
;
// "generic" handler that gets put in the tp_* slot which proxies to the python version
wrapperfunc
wrapper
;
// "wrapper" that ends up getting called by the Python-visible WrapperDescr
const
char
*
doc
;
const
llvm
::
StringRef
doc
;
int
flags
;
// exists in CPython: PyObject *name_strobj
};
...
...
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