Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
02a5f1e0
Commit
02a5f1e0
authored
Jan 05, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move __Pyx_InitStrings() utility function into StringTools.c
parent
b07b750e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
41 deletions
+37
-41
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+1
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+0
-38
Cython/Utility/StringTools.c
Cython/Utility/StringTools.c
+36
-0
No files found.
Cython/Compiler/Code.py
View file @
02a5f1e0
...
...
@@ -1127,9 +1127,7 @@ class GlobalState(object):
py_strings
.
append
((
c
.
cname
,
len
(
py_string
.
cname
),
py_string
))
if
py_strings
:
import
Nodes
self
.
use_utility_code
(
Nodes
.
init_string_tab_utility_code
)
self
.
use_utility_code
(
UtilityCode
.
load_cached
(
"InitStrings"
,
"StringTools.c"
))
py_strings
.
sort
()
w
=
self
.
parts
[
'pystring_table'
]
w
.
putln
(
""
)
...
...
Cython/Compiler/Nodes.py
View file @
02a5f1e0
...
...
@@ -8039,44 +8039,6 @@ bad:
#------------------------------------------------------------------------------------
init_string_tab_utility_code
=
UtilityCode
(
proto
=
"""
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
"""
,
impl
=
"""
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
while (t->p) {
#if PY_MAJOR_VERSION < 3
if (t->is_unicode) {
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
} else if (t->intern) {
*t->p = PyString_InternFromString(t->s);
} else {
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
}
#else /* Python 3+ has unicode identifiers */
if (t->is_unicode | t->is_str) {
if (t->intern) {
*t->p = PyUnicode_InternFromString(t->s);
} else if (t->encoding) {
*t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
} else {
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
}
} else {
*t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
}
#endif
if (!*t->p)
return -1;
++t;
}
return 0;
}
"""
)
#------------------------------------------------------------------------------------
# Note that cPython ignores PyTrace_EXCEPTION,
# but maybe some other profilers don't.
...
...
Cython/Utility/StringTools.c
View file @
02a5f1e0
...
...
@@ -7,6 +7,42 @@
#include <string>
//////////////////// InitStrings.proto ////////////////////
static
int
__Pyx_InitStrings
(
__Pyx_StringTabEntry
*
t
);
/*proto*/
//////////////////// InitStrings ////////////////////
static
int
__Pyx_InitStrings
(
__Pyx_StringTabEntry
*
t
)
{
while
(
t
->
p
)
{
#if PY_MAJOR_VERSION < 3
if
(
t
->
is_unicode
)
{
*
t
->
p
=
PyUnicode_DecodeUTF8
(
t
->
s
,
t
->
n
-
1
,
NULL
);
}
else
if
(
t
->
intern
)
{
*
t
->
p
=
PyString_InternFromString
(
t
->
s
);
}
else
{
*
t
->
p
=
PyString_FromStringAndSize
(
t
->
s
,
t
->
n
-
1
);
}
#else
/* Python 3+ has unicode identifiers */
if
(
t
->
is_unicode
|
t
->
is_str
)
{
if
(
t
->
intern
)
{
*
t
->
p
=
PyUnicode_InternFromString
(
t
->
s
);
}
else
if
(
t
->
encoding
)
{
*
t
->
p
=
PyUnicode_Decode
(
t
->
s
,
t
->
n
-
1
,
t
->
encoding
,
NULL
);
}
else
{
*
t
->
p
=
PyUnicode_FromStringAndSize
(
t
->
s
,
t
->
n
-
1
);
}
}
else
{
*
t
->
p
=
PyBytes_FromStringAndSize
(
t
->
s
,
t
->
n
-
1
);
}
#endif
if
(
!*
t
->
p
)
return
-
1
;
++
t
;
}
return
0
;
}
//////////////////// BytesContains.proto ////////////////////
static
CYTHON_INLINE
int
__Pyx_BytesContains
(
PyObject
*
bytes
,
char
character
);
/*proto*/
...
...
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