zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re:  PATCH: 3.1.5-pws-8: dumping completions for speed
Date: Tue, 16 Feb 1999 16:15:47 +0100 (MET)	[thread overview]
Message-ID: <199902161515.QAA02910@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Sven Wischnowsky's message of Tue, 16 Feb 1999 15:23:38 +0100 (MET)


I wrote:

> Peter Stephenson wrote:
>
> > 4) I just made it check for $0.dump in init, so if it had to search the
> > path for init, it won't find init.dump (that's why perl sets $0 to a full
> > path name).
> 
> How about making this the default, but if the user has set a parameter 
> (COMPDUMP or something) and that contains the name of a file, source
> that one?

The patch below adds this (set COMPDUMP to the file name you want to
use before dotting init, $0.dump is the default).

It also adds an experimental auto-dumping. If the parameter AUTODUMP
is set to `yes' when init is dotted, it will automatically dump the
state on first invocation or if it thinks the number completion files
has changed. Hm, does this look like the right thing?

Bye
 Sven

diff -u of/Completion/dump Functions/Completion/dump
--- of/Completion/dump	Tue Feb 16 16:04:04 1999
+++ Functions/Completion/dump	Tue Feb 16 16:13:05 1999
@@ -11,6 +11,14 @@
 #
 # It relies on KSH_ARRAYS not being set.
 
+# Print the number of files used for completion. This is used in init
+# to see if auto-dump should re-dump the dump-file.
+
+__d_files=( ${^~fpath}/__*~*~ )
+
+print "#files: $#__d_files"
+
+unset __d_files
 
 # First dump the arrays comps, patcomps and keycomps; the middle one
 # is an ordinary array, the other two are associative.  The
diff -u of/Completion/init Functions/Completion/init
--- of/Completion/init	Tue Feb 16 15:03:00 1999
+++ Functions/Completion/init	Tue Feb 16 16:10:40 1999
@@ -208,10 +208,20 @@
   fi
 }
 
+__i_files=( ${^~fpath}/__*~*~ )
+__i_initname=$0
+__i_dumpname=${COMPDUMP-$0.dump}
+__i_done=''
 
-if [[ -f $0.dump ]]; then
-  . $0.dump
-else
+if [[ -f $__i_dumpname ]]; then
+  read -rA __i_line < $__i_dumpname
+  if [[ "$AUTODUMP" != yes || $__i_line[2] -eq $#__i_files ]]; then
+    builtin . $__i_dumpname
+    __i_done=yes
+  fi
+  unset __i_line
+fi
+if [[ -z "$__i_done" ]]; then
   # Now we make the files automatically autoloaded.
   for __i_dir in $fpath; do
     [[ $__i_dir = . ]] && continue
@@ -254,4 +264,8 @@
 	    done
 
   unset __i_dir __i_line __i_file
+
+  [[ "$AUTODUMP" = yes ]] && builtin . ${__i_initname:h}/dump > $__i_dumpname
 fi
+
+unset __i_files __i_initname __i_dumpname __i_done

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


             reply	other threads:[~1999-02-16 15:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-16 15:15 Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-02-16 14:23 Sven Wischnowsky
1999-02-15 14:46 Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199902161515.QAA02910@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).