From 6629a8d8334cb8cd20dade64bdf48522cc5ff4cf Mon Sep 17 00:00:00 2001 From: terry Date: Fri, 26 Jun 1998 15:42:01 +0000 Subject: [PATCH] Patch from Artem Belevich -- greatly increase speed when rebuilding database by caching everything. Probably makes the runtime huge, but who cares? git-svn-id: svn://10.0.0.236/trunk@4574 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bonsai/globals.tcl | 30 +++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/mozilla/webtools/bonsai/globals.tcl b/mozilla/webtools/bonsai/globals.tcl index 0a35ad9242f..09cbbdbcb79 100755 --- a/mozilla/webtools/bonsai/globals.tcl +++ b/mozilla/webtools/bonsai/globals.tcl @@ -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 }