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
0724433e
Commit
0724433e
authored
Oct 16, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More microoptimizations
parent
dff9c845
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
from_cpython/Modules/_sre.c
from_cpython/Modules/_sre.c
+4
-5
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+14
-1
src/runtime/str.cpp
src/runtime/str.cpp
+6
-1
No files found.
from_cpython/Modules/_sre.c
View file @
0724433e
...
...
@@ -3538,13 +3538,12 @@ _pair(Py_ssize_t i1, Py_ssize_t i2)
}
static
PyObject
*
match_span
(
MatchObject
*
self
,
PyObject
*
args
)
match_span
(
MatchObject
*
self
,
PyObject
*
index_
)
{
Py_ssize_t
index
;
PyObject
*
index_
=
Py_False
;
/* zero */
if
(
!
PyArg_UnpackTuple
(
args
,
"span"
,
0
,
1
,
&
index_
))
return
NULL
;
if
(
!
index_
)
index_
=
Py_False
;
/* zero */
index
=
match_getindex
(
self
,
index_
);
...
...
@@ -3682,7 +3681,7 @@ static PyMethodDef match_methods[] = {
{
"group"
,
(
PyCFunction
)
match_group
,
METH_VARARGS
,
match_group_doc
},
{
"start"
,
(
PyCFunction
)
match_start
,
METH_VARARGS
,
match_start_doc
},
{
"end"
,
(
PyCFunction
)
match_end
,
METH_VARARGS
,
match_end_doc
},
{
"span"
,
(
PyCFunction
)
match_span
,
METH_
VARARGS
,
match_span_doc
},
{
"span"
,
(
PyCFunction
)
match_span
,
METH_
O
|
METH_D1
,
match_span_doc
},
{
"groups"
,
(
PyCFunction
)
match_groups
,
METH_VARARGS
|
METH_KEYWORDS
,
match_groups_doc
},
{
"groupdict"
,
(
PyCFunction
)
match_groupdict
,
METH_VARARGS
|
METH_KEYWORDS
,
...
...
src/runtime/objmodel.cpp
View file @
0724433e
...
...
@@ -3559,7 +3559,20 @@ void rearrangeArgumentsInternal(ParamReceiveSpec paramspec, const ParamNames* pa
}
}
Box
*
ovarargs
=
BoxedTuple
::
create
(
unused_positional
.
size
(),
unused_positional
.
data
());
Box
*
ovarargs
;
if
(
argspec
.
num_args
==
0
&&
paramspec
.
num_args
==
0
&&
(
!
varargs
||
varargs
->
cls
==
tuple_cls
))
{
// We probably could have cut out a lot more of the overhead in this case:
assert
(
varargs_size
==
unused_positional
.
size
());
if
(
!
varargs
)
ovarargs
=
EmptyTuple
;
else
ovarargs
=
varargs
;
}
else
{
ovarargs
=
BoxedTuple
::
create
(
unused_positional
.
size
(),
unused_positional
.
data
());
}
assert
(
ovarargs
->
cls
==
tuple_cls
);
getArg
(
varargs_idx
,
oarg1
,
oarg2
,
oarg3
,
oargs
)
=
ovarargs
;
}
else
if
(
unused_positional
.
size
())
{
raiseExcHelper
(
TypeError
,
"%s() takes at most %d argument%s (%ld given)"
,
func_name_cb
(),
paramspec
.
num_args
,
...
...
src/runtime/str.cpp
View file @
0724433e
...
...
@@ -1867,7 +1867,8 @@ Box* strReplace(Box* _self, Box* _old, Box* _new, Box** _args) {
std
::
string
s
=
self
->
s
();
bool
single_char
=
old
->
size
()
==
1
;
for
(
int
num_replaced
=
0
;
num_replaced
<
max_replaces
||
max_replaces
<
0
;
++
num_replaced
)
{
int
num_replaced
=
0
;
for
(;
num_replaced
<
max_replaces
||
max_replaces
<
0
;
++
num_replaced
)
{
if
(
single_char
)
start_pos
=
s
.
find
(
old
->
s
()[
0
],
start_pos
);
else
...
...
@@ -1878,6 +1879,10 @@ Box* strReplace(Box* _self, Box* _old, Box* _new, Box** _args) {
s
.
replace
(
start_pos
,
old
->
size
(),
new_
->
s
());
start_pos
+=
new_
->
size
();
// Handles case where 'to' is a substring of 'from'
}
if
(
num_replaced
==
0
&&
self
->
cls
==
str_cls
)
return
self
;
return
boxString
(
s
);
}
...
...
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