1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Prevent array reallocation

This commit is contained in:
Takashi Kokubun 2015-11-28 11:54:48 +09:00
parent 7a9fc74262
commit 360c454ed5

View file

@ -29,21 +29,20 @@ rb_escape_html(RB_UNUSED_VAR(VALUE self), VALUE str)
static VALUE
attr_build_id(VALUE escape_attrs, VALUE ids)
{
VALUE truthy_ids, id, attr_value;
int i, len;
VALUE id, attr_value;
long i, len;
ids = rb_funcall(ids, id_flatten, 0);
len = RARRAY_LEN(ids);
truthy_ids = rb_ary_new2(len);
for (i = 0; i < len; i++) {
for (i = len - 1; 0 <= i; i--) {
id = rb_ary_entry(ids, i);
if (RTEST(id)) {
rb_ary_push(truthy_ids, id);
if (!RTEST(id)) {
rb_ary_delete_at(ids, i);
}
}
attr_value = rb_ary_join(truthy_ids, rb_const_get(mAttributeBuilder, id_underscore));
attr_value = rb_ary_join(ids, rb_const_get(mAttributeBuilder, id_underscore));
if (RTEST(escape_attrs)) {
attr_value = escape_html(attr_value);
}