File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 4
4
"cmp"
5
5
"strings"
6
6
"unicode"
7
+ "unsafe"
7
8
8
9
"github.com/microsoft/typescript-go/internal/stringutil"
9
10
)
@@ -606,7 +607,12 @@ func ToFileNameLowerCase(fileName string) string {
606
607
}
607
608
b [i ] = c
608
609
}
609
- return string (b )
610
+ // SAFETY: `b` is a freshly allocated, non-empty byte slice whose contents are
611
+ // fully initialized. We do not mutate `b` after this point, and the returned
612
+ // string becomes the only live reference to its backing array. The array is
613
+ // heap-allocated (via make), so the GC keeps it alive for the lifetime of the
614
+ // returned string. Since len(b) > 0 here, &b[0] is a valid pointer.
615
+ return unsafe .String (& b [0 ], len (b ))
610
616
}
611
617
612
618
return strings .Map (func (r rune ) rune {
You can’t perform that action at this time.
0 commit comments