[EMAIL PROTECTED] (Kim F. Storm) writes: > I noticed that xml.el has several occurences of code like this: > > ((looking-at (concat "<!ENTITY[ \t\n\r]*\\(" xml-name-re > "\\)[ \t\n\r]*\\(" xml-entity-value-re > "\\)[ \t\n\r]*>")) > (let ((name (buffer-substring (nth 2 (match-data)) > (nth 3 (match-data)))) > (value (buffer-substring (+ (nth 4 (match-data)) 1) > (- (nth 5 (match-data)) 1)))) > (goto-char (nth 1 (match-data))) > > > Using (match-data) like that is VERY, VERY inefficient.
Uh, that is only half the story. It is not just devastatingly inefficient by itself. Every single such call creates a whole slew of markers, and those slow down _any_ text manipulation in the buffer _afterwards_ until they get garbage-collected at some indeterminate point of time in the future. The code passage above creates 30 new markers _every_ time it is run. All of these are maintained for every insertion/deletion in the buffer until garbage collection finally removes them. > Use either match-beginning/match-end, or match-string instead. Yes, yes, YES! -- David Kastrup, Kriemhildstr. 15, 44793 Bochum _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel