From 4cb68c4a4df5a3150cfffaff9bb4324af2091780 Mon Sep 17 00:00:00 2001 From: Alfredo Beaumont Date: Fri, 11 Jul 2008 10:53:51 +0200 Subject: [PATCH] Open every source file just once. This make code work ~20x faster --- extra/ctags/etags/etags.factor | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/extra/ctags/etags/etags.factor b/extra/ctags/etags/etags.factor index 75fe249538..94928a263e 100644 --- a/extra/ctags/etags/etags.factor +++ b/extra/ctags/etags/etags.factor @@ -5,7 +5,7 @@ ! Alfredo Beaumont USING: kernel sequences sorting assocs words prettyprint ctags io.encodings.ascii io.files math math.parser namespaces strings locals -shuffle io.backend memoize ; +shuffle io.backend arrays ; IN: ctags.etags : ctag-path ( alist -- path ) @@ -39,20 +39,20 @@ IN: ctags.etags ] 2keep line>bytes + ] if ; -: file>bytes ( n path -- bytes ) - ascii file-lines lines>bytes ; +: file>lines ( resource -- lines ) + ascii file-lines ; -: etag ( path seq -- str ) +: etag ( lines seq -- str ) [ dup first ?word-name % 1 HEX: 7f % second dup number>string % 1 CHAR: , % - 2 - swap file>bytes number>string % + 2 - swap lines>bytes number>string % ] "" make ; -: etag-entry ( alist -- alist path ) - [ first ] keep swap ; +: etag-entry ( alist -- alist array ) + [ first ] keep swap [ file>lines ] keep 2array ; : vector-length ( vector -- n ) 0 [ length + ] reduce ; @@ -73,9 +73,9 @@ SYMBOL: resource { } swap [ etag-entry resource [ second [ - resource get swap etag + resource get first swap etag ] map dup vector-length - resource get + resource get second ] with-variable etag-header append ] each ;