Disable `Symbol.all_symbols`.
MODIFY
include/mrbconf.h
include/mrbconf.h
/* -DMRB_ENABLE_XXXX to enable following features */
//#define MRB_ENABLE_DEBUG_HOOK /* hooks for debugger */
+//#define MRB_ENABLE_ALL_SYMBOLS /* Symbols.all_symbols */
/* end of configuration */

MODIFY
mrbgems/mruby-symbol-ext/src/symbol.c
mrbgems/mruby-symbol-ext/src/symbol.c
#include <mruby/array.h>
#include <mruby/string.h>
-typedef struct symbol_name {
- size_t len;
- const char *name;
-} symbol_name;
-
/*
* call-seq:
* Symbol.all_symbols => array
@@ -23,6 +18,7 @@ typedef struct symbol_name {
* :Tms, :getwd, :$=, :ThreadGroup,
* :wait2, :$>]
*/
+#ifdef MRB_ENABLE_ALL_SYMBOLS
static mrb_value
mrb_sym_all_symbols(mrb_state *mrb, mrb_value self)
{
@@ -36,6 +32,7 @@ mrb_sym_all_symbols(mrb_state *mrb, mrb_value self)
return ary;
}
+#endif
/*
* call-seq:
@@ -61,7 +58,9 @@ void
mrb_mruby_symbol_ext_gem_init(mrb_state* mrb)
{
struct RClass *s = mrb->symbol_class;
+#ifdef MRB_ENABLE_ALL_SYMBOLS
mrb_define_class_method(mrb, s, "all_symbols", mrb_sym_all_symbols, MRB_ARGS_NONE());
+#endif
mrb_define_method(mrb, s, "length", mrb_sym_length, MRB_ARGS_NONE());
mrb_define_method(mrb, s, "size", mrb_sym_length, MRB_ARGS_NONE());
}

MODIFY
mrbgems/mruby-symbol-ext/test/symbol.rb
mrbgems/mruby-symbol-ext/test/symbol.rb
+# coding: utf-8
##
# Symbol(Ext) Test
+if Symbol.respond_to?(:all_symbols)
assert('Symbol.all_symbols') do
foo = [:__symbol_test_1, :__symbol_test_2, :__symbol_test_3].sort
symbols = Symbol.all_symbols.select{|sym|sym.to_s.include? '__symbol_test'}.sort
assert_equal foo, symbols
end
+end
%w[size length].each do |n|
assert("Symbol##{n}") do

MODIFY
src/symbol.c
src/symbol.c
@@ -28,6 +28,7 @@ sym_validate_len(mrb_state *mrb, size_t len)
}
}
+#ifndef MRB_ENABLE_ALL_SYMBOLS
static char pack_table[] = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
static mrb_sym
@@ -100,6 +101,7 @@ sym_inline_unpack(mrb_sym sym, char *buf)
buf[i] = '\0';
return buf;
}
+#endif
uint8_t
symhash(const char *key, size_t len)
@@ -123,9 +125,11 @@ find_symbol(mrb_state *mrb, const char *name, uint16_t len, uint8_t hash)
mrb_sym i;
symbol_name *sname;
+#ifndef MRB_ENABLE_ALL_SYMBOLS
/* inline symbol */
i = sym_inline_pack(name, len);
if (i > 0) return i;
+#endif
i = mrb->symhash[hash];
if (i == 0) return 0;
@@ -247,11 +251,13 @@ mrb_check_intern_str(mrb_state *mrb, mrb_value str)
MRB_API const char*
mrb_sym2name_len(mrb_state *mrb, mrb_sym sym, mrb_int *lenp)
{
+#ifndef MRB_ENABLE_ALL_SYMBOLS
if (sym & 1) { /* inline packed symbol */
sym_inline_unpack(sym, mrb->symbuf);
if (lenp) *lenp = strlen(mrb->symbuf);
return mrb->symbuf;
}
+#endif
sym >>= 1;
if (sym == 0 || mrb->symidx < sym) {

Disable `Symbol.all_symbols`.