File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ tex-fmt is over a thousand times faster than latexindent.
174
174
175
175
| ** Files** | ** Lines** | ** Size** | ** tex-fmt** | ** latexindent** | ** latexindent -m** |
176
176
| --- | --- | --- | --- | --- | --- |
177
- | 49 | 94k | 3.5M | ** 0.065s ** | 99s [ x1523 ] | 132s [ x2031 ] |
177
+ | 49 | 94k | 3.5M | ** 0.055s ** | 99s [ x1800 ] | 132s [ x2400 ] |
178
178
179
179
## Contribution
180
180
Original file line number Diff line number Diff line change @@ -68,11 +68,14 @@ fn get_back(line: &str, pattern: &Pattern) -> i8 {
68
68
let mut back: i8 = 0 ;
69
69
let mut cumul: i8 = 0 ;
70
70
71
- // delimiters
72
- for c in line. chars ( ) {
73
- cumul -= i8:: from ( OPENS . contains ( & c) ) ;
74
- cumul += i8:: from ( CLOSES . contains ( & c) ) ;
75
- back = max ( cumul, back) ;
71
+ // Dedent delimiters
72
+ // Check first whether there are any closing delimiters
73
+ if CLOSES . iter ( ) . any ( |c| line. contains ( * c) ) {
74
+ for c in line. chars ( ) {
75
+ cumul -= i8:: from ( OPENS . contains ( & c) ) ;
76
+ cumul += i8:: from ( CLOSES . contains ( & c) ) ;
77
+ back = max ( cumul, back) ;
78
+ }
76
79
}
77
80
78
81
// other environments get single indents
You can’t perform that action at this time.
0 commit comments