helly           Sat Feb 22 18:47:10 2003 EDT

  Modified files:              
    /php4/ext/dba/libinifile    inifile.c 
  Log:
  Dropped optimization
  # It is impossible to combine skip=-1 searches with firstkey/nextkey results
  
Index: php4/ext/dba/libinifile/inifile.c
diff -u php4/ext/dba/libinifile/inifile.c:1.3 php4/ext/dba/libinifile/inifile.c:1.4
--- php4/ext/dba/libinifile/inifile.c:1.3       Sat Feb 22 15:49:07 2003
+++ php4/ext/dba/libinifile/inifile.c   Sat Feb 22 18:47:09 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: inifile.c,v 1.3 2003/02/22 20:49:07 helly Exp $ */
+/* $Id: inifile.c,v 1.4 2003/02/22 23:47:09 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -44,7 +44,7 @@
 /* {{{ inifile_version */
 char *inifile_version() 
 {
-       return "1.0, $Revision: 1.3 $";
+       return "1.0, $Revision: 1.4 $";
 }
 /* }}} */ 
 
@@ -254,40 +254,12 @@
        val_type val;
        int res, grp_eq = 0;
 
-       if (skip == -1) {
-               if (dba->next.key.group && dba->next.key.name && 
!inifile_key_cmp(&dba->next.key, key TSRMLS_CC)) {
-                       /* we got it already from last fetch */
-                       val.value = estrdup(dba->next.val.value ? dba->next.val.value 
: "");
-                       /* allow faster access by automatically getting next key */
-                       php_stream_seek(dba->fp, dba->next.pos, SEEK_SET);
-                       ln.key.group = estrdup(dba->next.key.group ? 
dba->next.key.group : "");
-                       inifile_read(dba, &ln TSRMLS_CC);
-                       inifile_line_free(&dba->next);
-                       dba->next = ln;
-                       return val;
-               } else if (dba->curr.key.group && dba->curr.key.name && 
!inifile_key_cmp(&dba->curr.key, key TSRMLS_CC)) {
-                       /* we got it already from firstkey/lastkey */
-                       /* 
-                        * this optimisation does not work when firstkey/nextkey found
-                        * any instance other than the one instance wanted.
-                        */
-                       val.value = estrdup(dba->curr.val.value ? dba->curr.val.value 
: "");
-                       /* allow faster access by automatically getting next key 
-                        * we must use the line pointer 'next' since we cannot change 
the 
-                        * line pointer of firstkey/nextkey
-                        */
-                       php_stream_seek(dba->fp, dba->curr.pos, SEEK_SET);
-                       ln.key.group = estrdup(dba->curr.key.group ? 
dba->curr.key.group : "");
-                       inifile_read(dba, &ln TSRMLS_CC);
-                       inifile_line_free(&dba->next);
-                       dba->next = ln;
-                       return val;
-               }
-       }
-
-       /* the slow way: restart and seacrch */
-       if (skip != -1 || !dba->next.key.group || !dba->next.key.name || 
inifile_key_cmp(&dba->next.key, key TSRMLS_CC)) {
+       if (skip == -1 && dba->next.key.group && dba->next.key.name && 
!inifile_key_cmp(&dba->next.key, key TSRMLS_CC)) {
+               /* we got position already from last fetch */
+               php_stream_seek(dba->fp, dba->next.pos, SEEK_SET);
+       } else {
                /* specific instance or not same key -> restart search */
+               /* the slow way: restart and seacrch */
                php_stream_rewind(dba->fp);
        }
        inifile_line_free(&dba->next);
@@ -298,10 +270,10 @@
                if (!(res=inifile_key_cmp(&ln.key, key TSRMLS_CC))) {
                        if (!skip) {
                                val.value = estrdup(ln.val.value ? ln.val.value : "");
-                               /* allow faster access by automatically getting next 
key */
-                               inifile_read(dba, &ln TSRMLS_CC);
+                               /* allow faster access by updating key read into next 
*/
                                inifile_line_free(&dba->next);
                                dba->next = ln;
+                               dba->next.pos = php_stream_tell(dba->fp);;
                                return val;
                        }
                        skip--;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to