@@ -76,6 +76,8 @@ public class CtagsReader {
76
76
*/
77
77
private static final int MAX_METHOD_LINE_LENGTH = 1030 ;
78
78
79
+ private static final int MAX_CUT_LENGTH = 2000 ;
80
+
79
81
/**
80
82
* E.g. krb5 src/kdc/kdc_authdata.c has a signature for handle_authdata()
81
83
* split across twelve lines, so use double that number.
@@ -90,6 +92,8 @@ public class CtagsReader {
90
92
private Supplier <SourceSplitter > splitterSupplier ;
91
93
private boolean triedSplitterSupplier ;
92
94
private SourceSplitter splitter ;
95
+ private long cutCacheKey ;
96
+ private String cutCacheValue ;
93
97
94
98
private int tabSize ;
95
99
@@ -760,12 +764,23 @@ private String trySplitterCut(int lineOffset, int maxLines) {
760
764
}
761
765
}
762
766
767
+ long newCutCacheKey = ((long )lineOffset << 32 ) | maxLines ;
768
+ if (cutCacheKey == newCutCacheKey ) {
769
+ return cutCacheValue ;
770
+ }
771
+
763
772
StringBuilder cutbld = new StringBuilder ();
764
773
for (int i = lineOffset ; i < lineOffset + maxLines &&
765
- i < splitter .count (); ++i ) {
774
+ i < splitter .count () && cutbld .length () < MAX_CUT_LENGTH ;
775
+ ++i ) {
766
776
cutbld .append (splitter .getLine (i ));
767
777
}
768
- return cutbld .toString ();
778
+ if (cutbld .length () > MAX_CUT_LENGTH ) {
779
+ cutbld .setLength (MAX_CUT_LENGTH );
780
+ }
781
+ cutCacheValue = cutbld .toString ();
782
+ cutCacheKey = newCutCacheKey ;
783
+ return cutCacheValue ;
769
784
}
770
785
771
786
/**
0 commit comments