Phillip Lord writes: > > > > Here is an idea I have for a patch. > > One of the few things about JDE that irritates me is substantial delay > that occurs when moving between one project and another, and the > setting of the JDE values that results. > > I tried profiling this process, and one of the things that surprised > me is that the main reason that the time is taken up is not in setting > the values, but resetting them all to their initial values. I often > use several projects at once and move backward and forward between > them. > > I've tried a couple of tricks to speed this up, several of which > failed. In the end it appears that a new algorithm is what is > required. I've come up with this one. > > Basically as far as I can see the JDE variables which are liable to be > different from the default values are those which have been set at > some point. Otherwise they will have the default values right? > > So if we get jde-set-variables to store all the symbols that have ever > been set, and just reset these every time we switch projects? Many of > us only move a few variables away from standard at any one > time. Obviously if a lot of variables were set from normal over time > the list of variables that have ever been set would build up rapidly > toward the full symbol list. > > Anyway to give you some idea at the performance difference we have > nearly an order of magnitude. In this case I have set or unset about > 20 different symbols (which is about 1/10th of the total number JDEE > has). > > with > > jde-load-project-file 2 0.302488 0.151244 > > without > > jde-load-project-file 2 2.524435 1.2622175 > > > Perhaps I am missing some occasions when this will fail. > > Any thoughts?
Hi Phil, I can't see any problems with your change and it really speeds up project switching. I added your code with a few minor changes (one to fix a small bug) to the JDEE sources. Thanks for providing this improvement. Paul > > Cheers > > Phil > > > > > > (defun jde-set-variables (&rest args) > "Initialize JDE customization variables. > > Takes a variable number of arguments. Each argument > should be of the form: > > (SYMBOL VALUE) > > The value of SYMBOL is set to VALUE. > " > (while args > (let ((entry (car args))) > (if (listp entry) > (let* ((symbol (nth 0 entry)) > (value (nth 1 entry)) > (customized (nth 2 entry)) > (set (or (and (local-variable-if-set-p symbol nil) 'set) > (get symbol 'custom-set) > 'set-default))) > > (push symbol jde-variables-that-have-been-set-list) > > > (if (or customized > jde-loaded-project-file-version) > (put symbol 'customized-value (list value))) > (if jde-loading-project > (progn > (jde-log-msg "jde-set-variables: Loading %S from project %s" symbol > jde-loading-project) > (jde-put-project symbol > jde-loading-project > (eval value))) > (jde-log-msg "jde-set-variables: Loading %S from unknown project" > symbol)) > (when (default-boundp symbol) > ;; Something already set this, overwrite it > (funcall set symbol (eval value))) > (setq args (cdr args))))))) > > > (defvar jde-variables-that-have-been-set-list nil) > > (defun jde-set-variables-init-value (&optional msg) > "Set each JDE variable to the value it has at Emacs startup." > (interactive) > (if (or (interactive-p) msg) > (message "Setting JDE variables to startup values...")) > (if jde-variables-that-have-been-set-list > (mapcar > 'jde-set-variable-init-value > ;;(jde-symbol-list) > jde-variables-that-have-been-set-list > ))) > > (defsubst jde-set-variable-init-value(symbol) > (let ((val-to-set (eval (car (or (get symbol 'saved-value) > (get symbol 'standard-value))))) > (set (or (get symbol 'custom-set) 'set-default))) > (if (or (get symbol 'customized-value) > (get symbol 'jde-project)) > (funcall set symbol val-to-set)) > (put symbol 'customized-value nil) > (put symbol 'jde-project nil) > (jde-put-project symbol "default" val-to-set))) >
