Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Kirill Smelkov
cpython
Commits
8a8e05a2
Commit
8a8e05a2
authored
May 22, 2006
by
Fredrik Lundh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
needforspeed: use memcpy for "long" strings; use a better algorithm
for long repeats.
parent
f1d60a53
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
Include/unicodeobject.h
Include/unicodeobject.h
+9
-4
Objects/unicodeobject.c
Objects/unicodeobject.c
+11
-4
No files found.
Include/unicodeobject.h
View file @
8a8e05a2
...
...
@@ -352,14 +352,19 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
Py_UNICODE_ISDIGIT(ch) || \
Py_UNICODE_ISNUMERIC(ch))
/* memcpy has a considerable setup overhead on many platforms; use a
loop for short strings (the "16" below is pretty arbitary) */
#define Py_UNICODE_COPY(target, source, length) do\
{int i; Py_UNICODE *t = (target); const Py_UNICODE *s = (source);\
for (i = 0; i < (length); i++) t[i] = s[i];\
{Py_ssize_t i_; Py_UNICODE *t_ = (target); const Py_UNICODE *s_ = (source);\
if (length > 16)\
memcpy(t_, s_, (length)*sizeof(Py_UNICODE));\
else\
for (i_ = 0; i_ < (length); i_++) t_[i_] = s_[i_];\
} while (0)
#define Py_UNICODE_FILL(target, value, length) do\
{
int i; Py_UNICODE *t = (target); Py_UNICODE v
= (value);\
for (i
= 0; i < (length); i++) t[i] = v
;\
{
Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_
= (value);\
for (i
_ = 0; i_ < (length); i_++) t_[i_] = v_
;\
} while (0)
#define Py_UNICODE_MATCH(string, offset, substring)\
...
...
Objects/unicodeobject.c
View file @
8a8e05a2
...
...
@@ -5900,11 +5900,18 @@ unicode_repeat(PyUnicodeObject *str, Py_ssize_t len)
if
(
str
->
length
==
1
&&
len
>
0
)
{
Py_UNICODE_FILL
(
p
,
str
->
str
[
0
],
len
);
}
else
while
(
len
--
>
0
)
{
}
else
{
int
done
=
0
;
/* number of characters copied this far */
if
(
done
<
nchars
)
{
Py_UNICODE_COPY
(
p
,
str
->
str
,
str
->
length
);
p
+=
str
->
length
;
}
done
=
str
->
length
;
}
while
(
done
<
nchars
)
{
int
n
=
(
done
<=
nchars
-
done
)
?
done
:
nchars
-
done
;
Py_UNICODE_COPY
(
p
+
done
,
p
,
n
);
done
+=
n
;
}
}
return
(
PyObject
*
)
u
;
}
...
...
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