Avoid the creation of too many strings in 'package'

Both when setting a path and searching for a file ('searchpath'),
this commit reduces the number of intermediate strings created
in Lua.
(For setting a path the change is not relevant, because this is
done only twice when loading the module. Anyway, it is a nice example
of how to use auxlib buffers to manipulate strings in the C API.)
This commit is contained in:
Roberto Ierusalimschy
2019-05-03 10:14:25 -03:00
parent b36e26f51b
commit b14609032c
4 changed files with 79 additions and 41 deletions

2
lgc.h
View File

@@ -127,7 +127,7 @@
/*
** some gc parameters are stored divided by 4 to allow a maximum value
** larger than 1000 in a 'lu_byte'.
** up to 1023 in a 'lu_byte'.
*/
#define getgcparam(p) ((p) * 4)
#define setgcparam(p,v) ((p) = (v) / 4)