mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-05 03:54:35 +00:00
Patch from Artem Belevich <ABelevic@ctron.com> -- greatly increase speed when rebuilding database by caching everything. Probably makes the runtime huge, but who cares?
This commit is contained in:
parent
790937f2af
commit
029dca3987
@ -85,13 +85,31 @@ proc SqlQuote {str} {
|
||||
}
|
||||
|
||||
|
||||
# proc GetId {table field value} {
|
||||
# global lastidcache
|
||||
# if {[info exists lastidcache($table)]} {
|
||||
# lassign lastidcache($table) cval id
|
||||
# if {[cequal $value $cval]} {
|
||||
# return $id
|
||||
# }
|
||||
# }
|
||||
# set qvalue [SqlQuote $value]
|
||||
# SendSQL "select id from $table where $field = '$qvalue'"
|
||||
# set result [lindex [FetchSQLData] 0]
|
||||
# if {[cequal $result ""]} {
|
||||
# SendSQL "insert into $table ($field) values ('$qvalue')"
|
||||
# SendSQL "select LAST_INSERT_ID()"
|
||||
# set result [lindex [FetchSQLData] 0]
|
||||
# }
|
||||
# set lastidcache($table) [list $value $result]
|
||||
# return $result
|
||||
# }
|
||||
|
||||
proc GetId {table field value} {
|
||||
global lastidcache
|
||||
if {[info exists lastidcache($table)]} {
|
||||
lassign lastidcache($table) cval id
|
||||
if {[cequal $value $cval]} {
|
||||
return $id
|
||||
}
|
||||
if {[info exists lastidcache($table,$field,$value)]} {
|
||||
set id $lastidcache($table,$field,$value)
|
||||
return $id
|
||||
}
|
||||
set qvalue [SqlQuote $value]
|
||||
SendSQL "select id from $table where $field = '$qvalue'"
|
||||
@ -101,7 +119,7 @@ proc GetId {table field value} {
|
||||
SendSQL "select LAST_INSERT_ID()"
|
||||
set result [lindex [FetchSQLData] 0]
|
||||
}
|
||||
set lastidcache($table) [list $value $result]
|
||||
set lastidcache($table,$field,$value) $result
|
||||
return $result
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user