This commit is contained in:
Schluffe
2026-09-04 13:57:52 +02:00
parent 71cfa64793
commit e961887953
24 changed files with 340 additions and 360 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ test("RingBuffer", () => {
expect(ring.buffer.length).toBe(4);
for (let i = 0; i < 8; i++) {
expect(claim(ring, (i) => i)).toBe(ring.buffer[i % 4]);
expect(claim(ring, (_) => {})).toBe(ring.buffer[i % 4]);
}
expect(ring.cursor).toBe(0);
+3 -2
View File
@@ -26,9 +26,10 @@ export function createRingBuffer<T extends object>(
};
}
export function claim<T>(ring: RingBuffer<T>, reset: (instance: T) => T): T {
export function claim<T>(ring: RingBuffer<T>, reset: (instance: T) => void): T {
const instance = ring.buffer[ring.cursor];
reset(instance);
ring.cursor = (ring.cursor + 1) & ring.mask;
return reset(instance);
return instance;
}
+3 -3
View File
@@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<rect width="16" height="16" fill="#ff00ff"/>
<rect width="8" height="8" fill="#000000"/>
<rect x="8" y="8" width="8" height="8" fill="#000000"/>
<rect width="16" height="16" fill="#ff00ff" />
<rect width="8" height="8" fill="#000000" />
<rect x="8" y="8" width="8" height="8" fill="#000000" />
</svg>

Before

Width:  |  Height:  |  Size: 220 B

After

Width:  |  Height:  |  Size: 226 B