Commit 5a302db8 authored by David Byers's avatar David Byers
Browse files

Fix Emacs 19 and 20 compatibility (I think). Fix race condition reading unread confs.

Detailed changes:
> 2004-07-12  David Byers  <byers@lysator.liu.se>
>
> 	* clienttypes.el (read-list-enter-read-info): When checking
> 	whether to append texts to an existing read-list item, don't check
> 	that conf-stats are eq. Just check that the conf-nos are the same.
>
> 	* prefetch.el (lyskom-prefetch-read-texts-handler): There was a
> 	race condition here which could cause unread texts never to be
> 	read properly.
>
> 	Provide hash-table-like functions in Emacs 19 and 20:
> 	* reading.el (lyskom-mship-cache-create): Use
> 	lyskom-make-hash-table instead of make-hash-table so compatibility
> 	defun is used when needed.
> 	(lyskom-mship-cache-get): Ditto for gethash.
> 	(lyskom-mship-cache-put): Ditto for puthash.
> 	(lyskom-mship-cache-del): Ditto for remhash.
>
> 	* compatibility.el (make-hash-table): Provide compatibility defun.
> 	(gethash): Ditto.
> 	(puthash): Ditto.
> 	(remhash): Ditto.
>
parent b580f9dd
2004-07-12 David Byers <byers@lysator.liu.se>
* clienttypes.el (read-list-enter-read-info): When checking
whether to append texts to an existing read-list item, don't check
that conf-stats are eq. Just check that the conf-nos are the same.
* prefetch.el (lyskom-prefetch-read-texts-handler): There was a
race condition here which could cause unread texts never to be
read properly.
Provide hash-table-like functions in Emacs 19 and 20:
* reading.el (lyskom-mship-cache-create): Use
lyskom-make-hash-table instead of make-hash-table so compatibility
defun is used when needed.
(lyskom-mship-cache-get): Ditto for gethash.
(lyskom-mship-cache-put): Ditto for puthash.
(lyskom-mship-cache-del): Ditto for remhash.
* compatibility.el (make-hash-table): Provide compatibility defun.
(gethash): Ditto.
(puthash): Ditto.
(remhash): Ditto.
2004-07-11 David Byers <byers@lysator.liu.se>
Performance improvements:
......
......@@ -222,7 +222,9 @@ will be inserted before it."
;; should become more efficient.
((and (eq type 'CONF)
(eq (read-info->type (car (cdr rlist))) 'CONF)
(eq conf-stat (read-info->conf-stat (car (cdr rlist)))))
(eq (conf-stat->conf-no conf-stat)
(conf-stat->conf-no (read-info->conf-stat
(car (cdr rlist))))))
(read-info-append-text-list
(car (cdr rlist))
(text-list->texts (read-info->text-list read-info)))
......
......@@ -542,6 +542,43 @@ Otherwise treat \\ in NEWTEXT string as special:
nil
(preceding-char))))))
(lyskom-function-alias make-hash-table (&rest args)
"Create and return a new hash table.
This is a limited emulation of the make-hash-table function available
in some Emacsen. It ignores all arguments. The only test supported is
`eq'."
(let ((test (car (cdr (memq ':test args)))))
(or (eq test 'eq) (lyskom-error "internal error: invalid hash function"))
(cons 'HASH nil)))
(lyskom-function-alias gethash (key table)
"Look up KEY in TABLE and return its associated value.
This is a limited emulation of the gethash function available in some
Emacsen. It does not support the default argument."
(cdr (assq key (cdr table))))
(lyskom-function-alias puthash (key value table)
"Associate KEY with VALUE in hash table TABLE.
If KEY is already present in table, replace its current value with
VALUE.
This is a limited emulation of the puthash function available in some
Emacsen."
(let ((tmp (assq key (cdr table))))
(if tmp
(setcdr tmp value)
(setcdr table (cons (cons key value) (cdr table))))))
(lyskom-function-alias remhash (key table)
"Remove KEY from TABLE.
This is a limited emulation of the remhash function available in some
Emacsen."
(let ((tmp (assq key (cdr table))))
(when tmp
(setcdr table (delq tmp (cdr table))))))
;;; ================================================================
......@@ -588,7 +625,8 @@ Otherwise treat \\ in NEWTEXT string as special:
(lyskom-make-self-evaluating :prompt-format)
(lyskom-make-self-evaluating :dead-ok)
(lyskom-make-self-evaluating :mark)
(lyskom-make-self-evaluating :may-interrupt)
(lyskom-make-self-evaluating :test)
(lyskom-make-self-evaluating :size)
)
......
......@@ -771,6 +771,11 @@ The MAPS must be consecutive. No gaps or overlaps are currently allowed."
(set-text-list->tail text-list (last (text-list->texts text-list))))
(set-text-list->length-internal text-list nil))
;;; FIXME: It would be useful if text-list->append would only append
;;; FIXME: unique numbers and not blindnly concatenate the two lists.
;;; FIXME: That would probably take care of any remaining problems
;;; FIXME: where some texts are listed twice in the to do list.
(defsubst text-list->append (text-list texts)
"Destructively append TEXTS to the end of TEXT-LIST."
(if (text-list->texts text-list)
......
......@@ -311,10 +311,10 @@ Then prefetch all info (texttree) of comments."
(lyskom-stop-prefetch)
(when membership
(unless (lyskom-try-get-membership (membership->conf-no membership) t)
(lyskom-add-memberships-to-membership (list membership))
(when (and (lyskom-visible-membership membership)
(lyskom-prefetch-map (membership->conf-no membership)
membership)))))
(lyskom-add-memberships-to-membership (list membership)))
(when (and (lyskom-visible-membership membership)
(lyskom-prefetch-map (membership->conf-no membership)
membership))))
(lyskom-start-prefetch))
......
......@@ -119,24 +119,24 @@ reasonable guess."
(defun lyskom-mship-cache-create ()
"Initialize the membership cache to empty."
(vector (make-hash-table :size 300 :test 'eq)
(vector (lyskom-make-hash-table :size 300 :test 'eq)
(lyskom-avltree-create 'lyskom-membership-<)))
(defun lyskom-mship-cache-get (conf-no)
"Get the membership for CONF-NO from the membership cache."
(gethash conf-no (lyskom-mship-cache-index)))
(lyskom-gethash conf-no (lyskom-mship-cache-index)))
(defun lyskom-mship-cache-put (mship)
"Add MSHIP to the membership cache."
(lyskom-avltree-enter (lyskom-mship-cache-data) mship)
(puthash (membership->conf-no mship) mship (lyskom-mship-cache-index)))
(lyskom-puthash (membership->conf-no mship) mship (lyskom-mship-cache-index)))
(defun lyskom-mship-cache-del (conf-no)
"Delete CONF-NO from the membership cache."
(let ((mship (lyskom-mship-cache-get conf-no)))
(when mship
(lyskom-avltree-delete (lyskom-mship-cache-data) mship)
(remhash conf-no (lyskom-mship-cache-index)))))
(lyskom-remhash conf-no (lyskom-mship-cache-index)))))
(defun lyskom-update-membership-positions ()
"Update the position field of all memberships."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment