fix translation taking a while if constants buffer is big
This commit is contained in:
6
gentest.ar
Normal file
6
gentest.ar
Normal 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")
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h> // for size_t
|
#include <stddef.h> // for size_t
|
||||||
|
|
||||||
#define CHUNK_SIZE 16
|
#define CHUNK_SIZE 1048576
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *data;
|
void *data;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h> // for size_t
|
#include <stddef.h> // for size_t
|
||||||
|
|
||||||
#define CHUNK_SIZE 16
|
#define CHUNK_SIZE 1048576
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *data;
|
void *data;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ void *arena_get(ConstantArena *arena, size_t offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t arena_push(ConstantArena *arena, const void *data, size_t length) {
|
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++) {
|
for (size_t i = 0; i <= (arena->size - length); i++) {
|
||||||
if (memcmp(data, arena->data + i, length) == 0) {
|
if (memcmp(data, arena->data + i, length) == 0) {
|
||||||
return i;
|
return i;
|
||||||
|
|||||||
Reference in New Issue
Block a user