mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-compiler: combine variable declaration with initialization
This commit is contained in:
@@ -2624,16 +2624,13 @@ nosplat(node *t)
|
||||
static mrb_sym
|
||||
attrsym(codegen_scope *s, mrb_sym a)
|
||||
{
|
||||
const char *name;
|
||||
mrb_int len;
|
||||
char *name2;
|
||||
|
||||
name = mrb_sym_name_len(s->mrb, a, &len);
|
||||
name2 = (char*)codegen_palloc(s,
|
||||
(size_t)len
|
||||
+ 1 /* '=' */
|
||||
+ 1 /* '\0' */
|
||||
);
|
||||
const char *name = mrb_sym_name_len(s->mrb, a, &len);
|
||||
char *name2 = (char*)codegen_palloc(s,
|
||||
(size_t)len
|
||||
+ 1 /* '=' */
|
||||
+ 1 /* '\0' */
|
||||
);
|
||||
mrb_assert_int_fit(mrb_int, len, size_t, SIZE_MAX);
|
||||
memcpy(name2, name, (size_t)len);
|
||||
name2[len] = '=';
|
||||
|
||||
@@ -7385,14 +7385,9 @@ mrb_load_detect_file_cxt(mrb_state *mrb, FILE *fp, mrb_ccontext *c)
|
||||
return mrb_load_exec(mrb, mrb_parse_file_continue(mrb, fp, leading.b, bufsize, c), c);
|
||||
}
|
||||
else {
|
||||
mrb_int binsize;
|
||||
uint8_t *bin;
|
||||
mrb_value bin_obj = mrb_nil_value(); /* temporary string object */
|
||||
mrb_value result;
|
||||
|
||||
binsize = bin_to_uint32(leading.h.binary_size);
|
||||
bin_obj = mrb_str_new(mrb, NULL, binsize);
|
||||
bin = (uint8_t*)RSTRING_PTR(bin_obj);
|
||||
mrb_int binsize = bin_to_uint32(leading.h.binary_size);
|
||||
mrb_value bin_obj = mrb_str_new(mrb, NULL, binsize);
|
||||
uint8_t *bin = (uint8_t*)RSTRING_PTR(bin_obj);
|
||||
if ((size_t)binsize > bufsize) {
|
||||
memcpy(bin, leading.b, bufsize);
|
||||
if (fread(bin + bufsize, binsize - bufsize, 1, fp) == 0) {
|
||||
@@ -7401,7 +7396,7 @@ mrb_load_detect_file_cxt(mrb_state *mrb, FILE *fp, mrb_ccontext *c)
|
||||
}
|
||||
}
|
||||
|
||||
result = mrb_load_irep_buf_cxt(mrb, bin, binsize, c);
|
||||
mrb_value result = mrb_load_irep_buf_cxt(mrb, bin, binsize, c);
|
||||
if (mrb_string_p(bin_obj)) mrb_str_resize(mrb, bin_obj, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -14214,14 +14214,9 @@ mrb_load_detect_file_cxt(mrb_state *mrb, FILE *fp, mrb_ccontext *c)
|
||||
return mrb_load_exec(mrb, mrb_parse_file_continue(mrb, fp, leading.b, bufsize, c), c);
|
||||
}
|
||||
else {
|
||||
mrb_int binsize;
|
||||
uint8_t *bin;
|
||||
mrb_value bin_obj = mrb_nil_value(); /* temporary string object */
|
||||
mrb_value result;
|
||||
|
||||
binsize = bin_to_uint32(leading.h.binary_size);
|
||||
bin_obj = mrb_str_new(mrb, NULL, binsize);
|
||||
bin = (uint8_t*)RSTRING_PTR(bin_obj);
|
||||
mrb_int binsize = bin_to_uint32(leading.h.binary_size);
|
||||
mrb_value bin_obj = mrb_str_new(mrb, NULL, binsize);
|
||||
uint8_t *bin = (uint8_t*)RSTRING_PTR(bin_obj);
|
||||
if ((size_t)binsize > bufsize) {
|
||||
memcpy(bin, leading.b, bufsize);
|
||||
if (fread(bin + bufsize, binsize - bufsize, 1, fp) == 0) {
|
||||
@@ -14230,7 +14225,7 @@ mrb_load_detect_file_cxt(mrb_state *mrb, FILE *fp, mrb_ccontext *c)
|
||||
}
|
||||
}
|
||||
|
||||
result = mrb_load_irep_buf_cxt(mrb, bin, binsize, c);
|
||||
mrb_value result = mrb_load_irep_buf_cxt(mrb, bin, binsize, c);
|
||||
if (mrb_string_p(bin_obj)) mrb_str_resize(mrb, bin_obj, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user