commit b58e472
Devine Lu Linvega
·
2026-06-13 17:06:38 +0000 UTC
parent 925d0d1
Added the path caching from uxncli
1 files changed,
+10,
-3
+10,
-3
1@@ -654,6 +654,8 @@ typedef struct {
2 } UxnFile;
3
4 static UxnFile ufs[2];
5+static char dir_cache[0x200];
6+static unsigned int dir_cache_len;
7
8 static inline unsigned int
9 put_text(Uint8 *dest, const char *text)
10@@ -747,9 +749,14 @@ file_write_dir(const char *p)
11 while(*p && ok && s < end) {
12 *s++ = *p;
13 if(*p++ == '/') {
14- s[-1] = '\0';
15- ok = is_dir_real(buf) || mkdir(buf, 0755) == 0;
16- s[-1] = '/';
17+ unsigned int seg_len = s - buf;
18+ if(seg_len <= dir_cache_len && !memcmp(buf, dir_cache, seg_len)) {
19+ // reuse
20+ } else {
21+ s[-1] = '\0', ok = is_dir_real(buf) || mkdir(buf, 0755) == 0, s[-1] = '/';
22+ if(ok)
23+ memcpy(dir_cache, buf, seg_len), dir_cache_len = seg_len;
24+ }
25 }
26 }
27 return ok && !*p;