Commit 222e8d6
committed
perf(fs): cache resolved allowed directories in safeDelete
Add getAllowedDirectories() helper that caches the path.resolve() calls
for allowed directories. Even though getOsTmpDir(), getSocketCacacheDir(),
and getSocketUserDir() are memoized, we were still calling path.resolve()
on them for every safeDelete/safeDeleteSync invocation.
Changes:
- Add getAllowedDirectories() helper function with _cachedAllowedDirs cache
- Replace inline allowedDirs array construction in both functions
- Cache populated once on first call, reused for process lifetime
Benefits:
- Eliminates repeated path.resolve() calls
- Reduces from O(n) to O(1) for directory resolution
- Combines benefits of memoized getters + cached resolved paths
- Applied to both safeDelete() and safeDeleteSync()1 parent 5546c6d commit 222e8d6
1 file changed
+27
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1056 | 1056 | | |
1057 | 1057 | | |
1058 | 1058 | | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
1059 | 1084 | | |
1060 | 1085 | | |
1061 | 1086 | | |
| |||
1096 | 1121 | | |
1097 | 1122 | | |
1098 | 1123 | | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | | - | |
1104 | | - | |
1105 | | - | |
1106 | | - | |
1107 | | - | |
1108 | | - | |
1109 | | - | |
1110 | | - | |
| 1124 | + | |
1111 | 1125 | | |
1112 | 1126 | | |
1113 | 1127 | | |
| |||
1182 | 1196 | | |
1183 | 1197 | | |
1184 | 1198 | | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
1193 | | - | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
| 1199 | + | |
1197 | 1200 | | |
1198 | 1201 | | |
1199 | 1202 | | |
| |||
0 commit comments