[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GNU Emacs 24 Performance Issues in 'add-text-properties

From: joseph . koziatek
Subject: GNU Emacs 24 Performance Issues in 'add-text-properties
Date: Wed, 3 Sep 2014 13:19:23 -0700 (PDT)
User-agent: G2/1.0

Hello All,

Recently I started using Gnu Emacs 24.3.1 on Redhat 5 which I built with X 
support. I've noticed that add-text-properties has a performance issue. Below 
is a simplified function I wrote many years ago to gray out C & C++ comments. I 
call it from find-file-hooks and other commands where I select a buffer to edit.
In Gnu Emacs 21.4.1 this routine is blistering fast on a buffer of C++ code 
11,000 lines long with lots of comments. Under Gnu Emacs 24.3.1 I experience a 
long delay.. 

If I comment out the calls to 'add-text-properties under 24.3.1, it is super 
fast, so the 'search-forward commands are not the bottleneck.  

It is the calls to 'add-text-properties causing the long delay.

The memory usage (virtual memory and physical memory) reported by ps aux 
--sort=-rss,-rss looks normal for both versions (VirtMemory=150Mb and Rss=30Mb) 

I'm running on a 16 Cpu box with 32 Gig ram, so I have plenty of horsepower.

Any help as to what can be causing this code to run so slow under Gnu Emacs 24 
is greatly appreciated. 

Thanks In Advance 


(setq comm-start  "/*" ) 
(setq comm-end    "*/" )
(setq slash2      "//" )

(defun mark-comments ()   ;; highlight all C comments...
       (setq savepos (point))
       (goto-char (point-min))
       (setq startc (search-forward comm-start nil t))
       (setq endc   (search-forward comm-end   nil t))
       (while (and startc endc)
           (add-text-properties (- startc 2) (- endc 0)  '(face           
'(:foreground  "gray")))
           (add-text-properties (- startc 2) (- endc 0)  '(rear-nonsticky t) )
           (add-text-properties (- startc 2) (- endc 0)  '(front-sticky t) )

           (setq startc (search-forward comm-start nil t))
           (setq endc   (search-forward comm-end   nil t))
       (goto-char (point-min))
       (setq startc (search-forward slash2 nil t))
       (while startc
          (add-text-properties (- startc 2 ) (point)  '(face           
'(:foreground  "gray")))
          (add-text-properties (- startc 2 ) (point)  '(rear-nonsticky t) )
          (add-text-properties (- startc 2 ) (point)  '(front-sticky t) )

          (setq startc (search-forward slash2 nil t))
       (goto-char savepos)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]