From dfa336cd7ddc437314f36ce505c29e0e0d93659f Mon Sep 17 00:00:00 2001 From: normal Date: Sun, 21 Sep 2014 03:26:47 +0000 Subject: 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 --- ChangeLog | 5 +++++ file.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index a8110e4d67..b5eb7e536b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Sep 21 12:19:29 2014 Eric Wong + + * 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 * lib/csv.rb: avoid unnecessary object allocations. diff --git a/file.c b/file.c index 34b2693430..f6271a3607 100644 --- a/file.c +++ b/file.c @@ -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 { -- cgit v1.2.3