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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
0353b956
Commit
0353b956
authored
Nov 08, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up some code redundancy
parent
bdb7757f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
32 deletions
+21
-32
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+21
-32
No files found.
Cython/Compiler/ExprNodes.py
View file @
0353b956
...
...
@@ -3319,8 +3319,8 @@ class IndexNode(ExprNode):
elif
self
.
is_temp
:
if
self
.
type
.
is_pyobject
:
error_value
=
'NULL'
if
self
.
index
.
type
.
is_int
:
index_code
=
self
.
index
.
result
()
if
self
.
base
.
type
is
list_type
:
function
=
"__Pyx_GetItemInt_List"
elif
self
.
base
.
type
is
tuple_type
:
...
...
@@ -3330,58 +3330,47 @@ class IndexNode(ExprNode):
code
.
globalstate
.
use_utility_code
(
TempitaUtilityCode
.
load_cached
(
"GetItemInt"
,
"ObjectHandling.c"
))
else
:
index_code
=
self
.
index
.
py_result
()
if
self
.
base
.
type
is
dict_type
:
function
=
"__Pyx_PyDict_GetItem"
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"DictGetItem"
,
"ObjectHandling.c"
))
else
:
function
=
"PyObject_GetItem"
code
.
putln
(
"%s = %s(%s, %s%s); if (!%s) %s"
%
(
self
.
result
(),
function
,
self
.
base
.
py_result
(),
index_code
,
self
.
extra_index_params
(
code
),
self
.
result
(),
code
.
error_goto
(
self
.
pos
)))
code
.
put_gotref
(
self
.
py_result
())
elif
self
.
type
.
is_unicode_char
and
self
.
base
.
type
is
unicode_type
:
assert
self
.
index
.
type
.
is_int
index_code
=
self
.
index
.
result
()
function
=
"__Pyx_GetItemInt_Unicode"
error_value
=
'(Py_UCS4)-1'
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"GetItemIntUnicode"
,
"StringTools.c"
))
code
.
putln
(
"%s = %s(%s, %s%s); if (unlikely(%s == (Py_UCS4)-1)) %s;"
%
(
self
.
result
(),
function
,
self
.
base
.
py_result
(),
index_code
,
self
.
extra_index_params
(
code
),
self
.
result
(),
code
.
error_goto
(
self
.
pos
)))
elif
self
.
base
.
type
is
bytearray_type
:
assert
self
.
index
.
type
.
is_int
assert
self
.
type
.
is_int
index_code
=
self
.
index
.
result
()
function
=
"__Pyx_GetItemInt_ByteArray"
error_value
=
'-1'
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"GetItemIntByteArray"
,
"StringTools.c"
))
code
.
putln
(
"%s = %s(%s, %s%s); if (unlikely(%s == -1)) %s;"
%
(
self
.
result
(),
function
,
self
.
base
.
py_result
(),
index_code
,
self
.
extra_index_params
(
code
),
self
.
result
(),
code
.
error_goto
(
self
.
pos
)))
else
:
assert
False
,
"unexpected type %s and base type %s for indexing"
%
(
self
.
type
,
self
.
base
.
type
)
if
self
.
index
.
type
.
is_int
:
index_code
=
self
.
index
.
result
()
else
:
index_code
=
self
.
index
.
py_result
()
code
.
putln
(
"%s = %s(%s, %s%s); if (unlikely(%s == %s)) %s;"
%
(
self
.
result
(),
function
,
self
.
base
.
py_result
(),
index_code
,
self
.
extra_index_params
(
code
),
self
.
result
(),
error_value
,
code
.
error_goto
(
self
.
pos
)))
if
self
.
type
.
is_pyobject
:
code
.
put_gotref
(
self
.
py_result
())
def
generate_setitem_code
(
self
,
value_code
,
code
):
if
self
.
index
.
type
.
is_int
:
if
self
.
base
.
type
is
bytearray_type
:
...
...
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