Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
26443005
Commit
26443005
authored
Feb 26, 2013
by
Manuel Mohr
Browse files
statev_sql: Cache and reuse context ids.
parent
abe4f6a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/statev_sql.py
View file @
26443005
...
...
@@ -145,14 +145,21 @@ class EmitSqlite3(EmitBase):
marks
=
","
.
join
([
"?"
]
*
len
(
ctxcols
))
self
.
ctxinsert
=
"insert into `%s` (%s) values (%s)"
%
(
self
.
ctxtab
,
keys
,
marks
)
self
.
contextids
=
dict
()
def
ev
(
self
,
curr_id
,
evitems
):
self
.
execute
(
self
.
evinsert
,
(
curr_id
,)
+
tuple
(
evitems
))
def
ctx
(
self
,
ctxitems
):
self
.
execute
(
self
.
ctxinsert
,
tuple
(
ctxitems
))
self
.
conn
.
commit
()
return
self
.
cursor
.
lastrowid
items
=
tuple
(
ctxitems
)
if
self
.
contextids
.
has_key
(
items
):
return
self
.
contextids
[
items
]
else
:
self
.
execute
(
self
.
ctxinsert
,
items
)
self
.
conn
.
commit
()
ctxid
=
self
.
cursor
.
lastrowid
self
.
contextids
[
items
]
=
ctxid
return
ctxid
def
commit
(
self
):
self
.
conn
.
commit
()
...
...
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