aboutsummaryrefslogtreecommitdiffstats
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-31 04:30:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-31 04:30:25 +0000
commit378161fe68f283599ce91cda3aaa3658af7c6e89 (patch)
tree04519222b65b8b8aea5199c56608e1e4b9c6dbb7 /dir.c
parent07bf69b0857d80b62e9fb1ac0886ee94ca8c2508 (diff)
downloadruby-378161fe68f283599ce91cda3aaa3658af7c6e89.tar.gz
dir.c: reduce string object
* dir.c (dir_each): get rid of allocate new string from UTF-8 string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/dir.c b/dir.c
index ad6793ffdc..f42a769d71 100644
--- a/dir.c
+++ b/dir.c
@@ -627,14 +627,13 @@ dir_each(VALUE dir)
size_t namlen = NAMLEN(dp);
VALUE path;
#if HAVE_HFS
- VALUE utf8str = Qnil;
if (hfs_p && has_nonascii(name, namlen) &&
- !NIL_P(utf8str = rb_str_normalize_ospath(name, namlen))) {
- RSTRING_GETMEM(utf8str, name, namlen);
+ !NIL_P(path = rb_str_normalize_ospath(name, namlen))) {
+ path = rb_external_str_with_enc(path, dirp->enc);
}
+ else
#endif
path = rb_external_str_new_with_enc(name, namlen, dirp->enc);
- IF_HAVE_HFS(if (!NIL_P(utf8str)) rb_str_resize(utf8str, 0));
rb_yield(path);
if (dirp->dir == NULL) dir_closed();
}