tla--face-add and tla--inventory-chose-face make tla-inventory slow.
About tla--face-add, I have no good idea to optimize it.
However, about tla--inventory-chose-face, we can use a table instead of
case.

I've taken a profile with/witout my patch on my private FreeType archive(over 
700 files).
The operation is tla-inventory-mark-file.

             With my patch and setting tla-highlight nil.

Function Name                                                   Call Count  
Elapsed Time  Average Time
==============================================================  ==========  
============  ============
tla-inventory-mark-file                                         1           
0.68821       0.68821
tla-inventory-printer                                           719         
0.6360109999  0.0008845771
tla--install-buffer-menu                                        1           
0.006176      0.006176
tla--buffers-menu                                               2           
0.005877      0.0029385
tla--face-add                                                   1438        
0.0055029999  3.826...e-06
tla--inventory-chose-face                                       719         
0.0026390000  3.670...e-06
tla--get-file-info-at-point                                     1           
0.000388      0.000388
tla-inventory-get-file-info-at-point                            1           
0.000362      0.000362
tla-inventory-cursor-goto                                       1           
2.7e-05       2.7e-05
tla-minibuffer-exit                                             1           
1.2e-05       1.2e-05
tla-minibuffer-setup                                            1           
1e-05         1e-05


           Without my patch and setting tla-highlight nil.

Function Name                                                   Call Count  
Elapsed Time  Average Time
==============================================================  ==========  
============  ============
tla-inventory-mark-file                                         1           
0.93407       0.93407
tla-inventory-printer                                           719         
0.644711      0.0008966773
tla--inventory-chose-face                                       719         
0.2487529999  0.0003459707
tla--install-buffer-menu                                        1           
0.00702       0.00702
tla--buffers-menu                                               2           
0.0067189999  0.0033594999
tla--face-add                                                   1438        
0.0054539999  3.792...e-06
tla--get-file-info-at-point                                     1           
0.000385      0.000385
tla-inventory-get-file-info-at-point                            1           
0.000362      0.000362
tla-inventory-cursor-goto                                       1           
2.7e-05       2.7e-05
tla-minibuffer-exit                                             1           
1.1e-05       1.1e-05
tla-minibuffer-setup                                            1           
1e-05         1e-05

Is this patch acceptable for 1.0?

BTW, Linux kernel includes 37164 files.

    [EMAIL PROTECTED] linux]# pwd
    /root/linux
    [EMAIL PROTECTED] linux]# find . | wc -l
    37164

Masatake YAMATO

--------------------------------------------------------------------------
* looking for [EMAIL PROTECTED] to compare with
* comparing to [EMAIL PROTECTED]

  M  lisp/xtla.el
                                                                        


* modified files

--- orig/lisp/xtla.el
+++ mod/lisp/xtla.el
@@ -1256,14 +1256,46 @@
             (ewoc-enter-last tla-inventory-cookie elem)))))
   (goto-char (point-min)))
 
+(defconst tla--inventory-chose-face-table
+  [
+    nil                                 ; ?B: 66->0
+    nil                                 ; 67
+    nil                                 ; 68
+    nil                                 ; 69
+    nil                                 ; 79
+    nil                                 ; 71
+    nil                                 ; 72
+    nil                                 ; 73
+    tla-junk                            ; ?J: 74->0
+    nil                                 ; 75
+    nil                                 ; 76
+    nil                                 ; 77
+    nil                                 ; 78
+    nil                                 ; 79
+    tla-precious                        ; ?P: 80
+    nil                                 ; 81
+    nil                                 ; 82
+    tla-source                          ; ?S: 83
+    tla-nested-tree                     ; :T: 84
+    tla-unrecognized                    ; :U: 85
+    ]
+  "type to face table used in 'tla--inventory-chose-face'")
+
 (defun tla--inventory-chose-face (type)
   "Return a face adapted to TYPE, which can be J, S, P, T or U."
-  (case type
-    (?P 'tla-precious)
-    (?U 'tla-unrecognized)
-    (?S 'tla-source)
-    (?J 'tla-junk)
-    (?T 'tla-nested-tree)))
+  (aref
+   tla--inventory-chose-face-table
+    (- type ?B)))
+
+;(defun tla--inventory-chose-face (type)
+;  "Return a face adapted to TYPE, which can be J, S, P, T or U."
+;  (case type
+;    (?J 'tla-junk)                      ; 74
+;    (?P 'tla-precious)                  ; 80
+;    (?S 'tla-source)                    ; 83
+;    (?T 'tla-nested-tree)               ; 84
+;    (?U 'tla-unrecognized)              ; 85
+;    ))
 
 (defun tla-inventory-printer (elem)
   "Ewoc printer for `tla-inventory-cookie'.





Reply via email to