#TUNING by cg
authorClaus Gittinger <cg@exept.de>
Tue, 12 Mar 2019 16:46:49 +0100
changeset 18668 615d5f2840de
parent 18667 6763622f6526
child 18669 a75316f60a29
#TUNING by cg class: Tools::TagList changed: #fromFile:in: tag search in big files.
Tools__TagList.st
--- a/Tools__TagList.st	Tue Mar 12 16:46:16 2019 +0100
+++ b/Tools__TagList.st	Tue Mar 12 16:46:49 2019 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 2002 by eXept Software AG 
 	      All Rights Reserved
@@ -2487,7 +2489,7 @@
     "create tags from a file;
      either use the ctags/etags command, or an internal naive, simple method."
 
-    |forceSimpleTagList list shellCmd numTags fileContents|
+    |forceSimpleTagList list shellCmd numTags fileContentsOrFilename|
 
     rawList := nil.
     tagsValidForFile := nil.
@@ -2529,15 +2531,19 @@
     tagTypesPresent := true.
 
     numTags := list size.
-    fileContents := aFile contents.
-
-    (numTags > 1 and:[fileContents notEmptyOrNil]) ifTrue:[
+    aFile fileSize <= (1024*1024) ifTrue:[
+        fileContentsOrFilename := aFile contents.
+    ] ifFalse:[
+        fileContentsOrFilename := aFile.
+    ].
+    
+    (numTags > 1) ifTrue:[
         numTags to:1 by:-1 do:[:i| 
             |tag lnr|
 
             tag := list at:i ifAbsent:nil.
 
-            lnr := tag lineNumberIn:fileContents.
+            lnr := tag lineNumberIn:fileContentsOrFilename.
             lnr == 0 ifTrue:[
                 list removeIndex:i
             ] ifFalse:[
@@ -2549,6 +2555,7 @@
     tagsValidForFile := aFile.
 
     "Modified: / 15-05-2017 / 00:56:22 / cg"
+    "Modified: / 12-03-2019 / 15:11:27 / Claus Gittinger"
 !
 
 fromFile:aFile in:aTempDirectory onTarget:aTarget