file.c: clear tmp buffer on failures

Reduces GC malloc pressure (MAXPATHLEN is 4096 on my system),
rb_find_file_safe hits this path at least twice every time
ruby starts.

* file.c (rb_find_file_ext_safe): clear tmp buffer on failure
  (rb_find_file_safe): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2014-09-21 03:26:47 +00:00
parent 5be5db6350
commit dfa336cd7d
2 changed files with 7 additions and 0 deletions

View File

@ -1,3 +1,8 @@
Sun Sep 21 12:19:29 2014 Eric Wong <e@80x24.org>
* file.c (rb_find_file_ext_safe): clear tmp buffer on failure
(rb_find_file_safe): ditto
Sat Sep 20 04:42:18 2014 Masaki Matsushita <glass.saga@gmail.com>
* lib/csv.rb: avoid unnecessary object allocations.

2
file.c
View File

@ -5609,6 +5609,7 @@ rb_find_file_ext_safe(VALUE *filep, const char *const *ext, int safe_level)
}
rb_str_set_len(fname, fnlen);
}
rb_str_resize(tmp, 0);
RB_GC_GUARD(load_path);
return 0;
}
@ -5661,6 +5662,7 @@ rb_find_file_safe(VALUE path, int safe_level)
if (rb_file_load_ok(f)) goto found;
}
}
rb_str_resize(tmp, 0);
return 0;
}
else {