This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
If I/O is an overhead when loading files, why not just slurp the whole thing in one go by using read (the c read, not the scheme one). If the file is too big you can fall back on the current behaviour, likewise for pipes and other sources. For example, boot-9 is about 80K, and we can easily afford that sort of amount of temporary buffer space. So something like static char* quick_read(char *filename) { FILE *file; int size; char *content; if((file = fopen(filename, "r")) == NULL) { I don't know what - whimper and whine; } fseek(file, 0, SEEK_END); size = ftell(file); rewind(file); content = scm_must_malloc(size); /* need to handle errors?*/ fread(content, 1, size, file); fclose(file); return (content); } /* caller must free content*/ No error handling or anything, but I bet it would be fast!! Julian Satchell <satchell@dera.gov.uk>