mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mrbconf.h option MRB_USE_ETEXT_EDATA to reduce memory.
on platforms with _etext and _edata, mruby can distinguish string literals so that it avoids memory allocation to copy them. for example, on my Linux box (x86 32bit), memory consumed by mrbtest decreased from 8,168,203 to 8,078,848 (reduced 88KB).
This commit is contained in:
@@ -211,4 +211,17 @@ mrb_undef_value(void)
|
||||
return v;
|
||||
}
|
||||
|
||||
#ifdef MRB_USE_ETEXT_EDATA
|
||||
extern char _etext[];
|
||||
extern char _edata[];
|
||||
|
||||
static inline mrb_bool
|
||||
mrb_ro_data_p(const char *p)
|
||||
{
|
||||
return _etext < p && p < _edata;
|
||||
}
|
||||
#else
|
||||
# define mrb_ro_data_p(p) FALSE
|
||||
#endif
|
||||
|
||||
#endif /* MRUBY_VALUE_H */
|
||||
|
||||
Reference in New Issue
Block a user