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
Gwenaël Samain
cython
Commits
860d2932
Commit
860d2932
authored
Jun 11, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor speed-ups in code writer
parent
7f9324d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+11
-9
No files found.
Cython/Compiler/Code.py
View file @
860d2932
...
...
@@ -33,10 +33,11 @@ class CCodeWriter:
def
__init__
(
self
,
f
):
#self.f = open_new_file(outfile_name)
self
.
f
=
f
self
.
_write
=
f
.
write
self
.
level
=
0
self
.
bol
=
1
self
.
marker
=
None
self
.
last_marker
=
1
self
.
last_marker
_line
=
0
self
.
label_counter
=
1
self
.
error_label
=
None
self
.
filename_table
=
{}
...
...
@@ -49,14 +50,14 @@ class CCodeWriter:
self
.
emit_marker
()
if
code
:
self
.
put
(
code
)
self
.
f
.
write
(
"
\
n
"
);
self
.
_
write
(
"
\
n
"
);
self
.
bol
=
1
def
emit_marker
(
self
):
self
.
f
.
write
(
"
\
n
"
);
self
.
_
write
(
"
\
n
"
);
self
.
indent
()
self
.
f
.
write
(
"/* %s */
\
n
"
%
self
.
marker
)
self
.
last_marker
=
self
.
marker
self
.
_write
(
"/* %s */
\
n
"
%
self
.
marker
[
1
]
)
self
.
last_marker
_line
=
self
.
marker
[
0
]
self
.
marker
=
None
def
put
(
self
,
code
):
...
...
@@ -65,7 +66,7 @@ class CCodeWriter:
self
.
level
+=
dl
if
self
.
bol
:
self
.
indent
()
self
.
f
.
write
(
code
)
self
.
_
write
(
code
)
self
.
bol
=
0
if
dl
>
0
:
self
.
level
+=
dl
...
...
@@ -85,7 +86,7 @@ class CCodeWriter:
self
.
putln
(
"}"
)
def
indent
(
self
):
self
.
f
.
write
(
" "
*
self
.
level
)
self
.
_
write
(
" "
*
self
.
level
)
def
get_py_version_hex
(
self
,
pyversion
):
return
"0x%02X%02X%02X%02X"
%
(
tuple
(
pyversion
)
+
(
0
,
0
,
0
,
0
))[:
4
]
...
...
@@ -105,6 +106,8 @@ class CCodeWriter:
if
pos
is
None
:
return
source_desc
,
line
,
col
=
pos
if
self
.
last_marker_line
==
line
:
return
assert
isinstance
(
source_desc
,
SourceDescriptor
)
contents
=
self
.
commented_file_contents
(
source_desc
)
...
...
@@ -114,8 +117,7 @@ class CCodeWriter:
marker
=
u'"%s":%d
\
n
%s
\
n
'
%
(
source_desc
.
get_escaped_description
(),
line
,
u'
\
n
'
.
join
(
lines
))
if
self
.
last_marker
!=
marker
:
self
.
marker
=
marker
self
.
marker
=
(
line
,
marker
)
def
init_labels
(
self
):
self
.
label_counter
=
0
...
...
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