Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
ecabb934
Commit
ecabb934
authored
Sep 19, 2008
by
Tiago Peixoto
Browse files
Avoid unnecessary string assembly inside inline()
parent
a4bff0c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/run_action/inline.py
View file @
ecabb934
...
...
@@ -37,6 +37,16 @@ cxxflags = libgraph_tool_core.mod_info().cxxflags + " -I%s" % inc_prefix
# this is the code template which defines the action function object
support_template
=
open
(
prefix
+
"/run_action/run_action_template.hh"
).
read
()
# property map types
props
=
""
for
d
in
[
"vertex"
,
"edge"
,
"graph"
]:
for
t
in
core
.
value_types
():
props
+=
((
"typedef typename %s_prop_t::template as<%s >::type"
+
\
" %sprop_%s_t;
\n
"
)
%
\
(
d
,
t
,
d
[
0
],
t
.
replace
(
" "
,
"_"
).
replace
(
"::"
,
"_"
)
\
.
replace
(
"<"
,
"_"
).
replace
(
">"
,
"_"
))).
\
replace
(
"__"
,
"_"
)
def
inline
(
g
,
code
,
arg_names
=
[],
local_dict
=
None
,
global_dict
=
None
,
force
=
0
,
compiler
=
"gcc"
,
verbose
=
0
,
auto_downcast
=
1
,
support_code
=
""
,
libraries
=
[],
...
...
@@ -49,19 +59,8 @@ def inline(g, code, arg_names=[], local_dict=None,
# we need to have different template names for each actions, to avoid
# strange RTTI issues. We'll therefore append an md5 hash of the code (plus
# grah_tool version string) to each action's name
import
hashlib
code_hash
=
hashlib
.
md5
(
code
+
core
.
__version__
).
hexdigest
()
# property map types
props
=
""
for
d
in
[
"vertex"
,
"edge"
,
"graph"
]:
for
t
in
core
.
value_types
():
props
+=
((
"typedef typename %s_prop_t::template as<%s >::type"
+
\
" %sprop_%s_t;
\n
"
)
%
\
(
d
,
t
,
d
[
0
],
t
.
replace
(
" "
,
"_"
).
replace
(
"::"
,
"_"
)
\
.
replace
(
"<"
,
"_"
).
replace
(
">"
,
"_"
))).
\
replace
(
"__"
,
"_"
)
# each term on the expansion will properly unwrap a tuple pointer value
# to a reference with the appropriate name and type
exp_term
=
"""typename boost::remove_pointer<typename tr1::tuple_element<%d,Args>::type>::type& %s =
...
...
Write
Preview
Supports
Markdown
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