fix translation taking a while if constants buffer is big

This commit is contained in:
2025-06-28 16:17:46 +01:00
parent aa65393e2c
commit 31f38d8ba4
4 changed files with 9 additions and 3 deletions

6
gentest.ar Normal file
View File

@@ -0,0 +1,6 @@
let myfile = file.write("rand_test.ar")
for (i from 0 to 1e6) do
myfile.text("\"")
myfile.text(string(random()))
myfile.text("\"\n")

View File

@@ -4,7 +4,7 @@
#include <stdbool.h>
#include <stddef.h> // for size_t
#define CHUNK_SIZE 16
#define CHUNK_SIZE 1048576
typedef struct {
void *data;

View File

@@ -4,7 +4,7 @@
#include <stdbool.h>
#include <stddef.h> // for size_t
#define CHUNK_SIZE 16
#define CHUNK_SIZE 1048576
typedef struct {
void *data;

View File

@@ -45,7 +45,7 @@ void *arena_get(ConstantArena *arena, size_t offset) {
}
size_t arena_push(ConstantArena *arena, const void *data, size_t length) {
if (arena->size >= length) {
if (arena->size >= length && arena->size<100000) {
for (size_t i = 0; i <= (arena->size - length); i++) {
if (memcmp(data, arena->data + i, length) == 0) {
return i;