Skip to content

Commit

Permalink
lib: Fix redundant mmap() calls for textures
Browse files Browse the repository at this point in the history
Only need to mmap() if we haven't loaded that texture yet.
  • Loading branch information
vkoskiv committed Oct 27, 2024
1 parent fac6749 commit a86e8b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/nodes/colornode.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const struct colorNode *build_color_node(struct cr_scene *s_ext, const struct cr
windowsFixPath(full);
}
const char *path = full ? full : desc->arg.image.full_path;
file_data data = file_load(path);
struct texture *tex = NULL;
// Note: We also deduplicate texture loads here, which ideally shouldn't be necessary.
for (size_t i = 0; i < scene->textures.count; ++i) {
Expand All @@ -53,13 +52,14 @@ const struct colorNode *build_color_node(struct cr_scene *s_ext, const struct cr
}
}
if (!tex) {
file_data data = file_load(path);
tex = load_texture(path, data);
texture_asset_arr_add(&scene->textures, (struct texture_asset){
.path = stringCopy(path),
.t = tex
});
file_free(&data);
}
file_free(&data);
const struct colorNode *new = newImageTexture(&s, tex, desc->arg.image.options);
if (full) free(full);
return new;
Expand Down

0 comments on commit a86e8b9

Please sign in to comment.