Using FindFirstFileA() instead of CreateFileA() to get the file size

Since we already call FindFirstFileA() and it returns the size there is
no need to open/close every file to get it's size
This commit is contained in:
2026-03-10 19:54:52 +01:00
parent 1fa306643f
commit f904337878
5 changed files with 77 additions and 17 deletions

View File

@@ -185,7 +185,7 @@ static void mpmc_push(MPMCQueue *q, void *item) {
}
/* ----------------------------------------------------------- */
/* POP */
/* POP (blocking with semaphore) */
/* ----------------------------------------------------------- */
static void *mpmc_pop(MPMCQueue *q) {
@@ -228,6 +228,52 @@ static void *mpmc_pop(MPMCQueue *q) {
return data;
}
/* ----------------------------------------------------------- */
/* TRY POP (non blocking) */
/* ----------------------------------------------------------- */
static b32 mpmc_try_pop(MPMCQueue *q, void **out) {
if (!plat_sem_trywait(&q->items_sem))
return false;
MPMCSlot *slot;
size_t pos;
int spins = 0;
for (;;) {
pos = atomic_load_explicit(&q->head, memory_order_relaxed);
slot = &q->slots[pos & q->mask];
size_t seq = atomic_load_explicit(&slot->seq, memory_order_acquire);
intptr_t diff = (intptr_t)seq - (intptr_t)(pos + 1);
if (likely(diff == 0)) {
if (atomic_compare_exchange_weak_explicit(&q->head, &pos, pos + 1,
memory_order_relaxed,
memory_order_relaxed))
break;
} else {
if (++spins > 10) {
SwitchToThread();
spins = 0;
} else {
cpu_pause();
}
}
}
*out = slot->data;
atomic_store_explicit(&slot->seq, pos + q->capacity, memory_order_release);
return true;
}
/* ----------------------------------------------------------- */
/* PUSH POISON */
/* ----------------------------------------------------------- */