* load.c (rb_require_internal): convert to path name with the
given safe level, without setting global safe level.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
To convert the object implicitly, it has had two parts in convert_type() which are
1. lookink up the method's id
2. calling the method
Seems that strncmp() and strcmp() in convert_type() are slightly heavy to look up
the method's id for type conversion.
This patch will add and use internal APIs (rb_convert_type_with_id, rb_check_convert_type_with_id)
to call the method without looking up the method's id when convert the object.
Array#flatten -> 19 % up
Array#+ -> 3 % up
[ruby-dev:50024] [Bug #13341] [Fix GH-1537]
### Before
Array#flatten 104.119k (± 1.1%) i/s - 525.690k in 5.049517s
Array#+ 1.993M (± 1.8%) i/s - 10.010M in 5.024258s
### After
Array#flatten 124.005k (± 1.0%) i/s - 624.240k in 5.034477s
Array#+ 2.058M (± 4.8%) i/s - 10.302M in 5.019328s
### Test Code
require 'benchmark/ips'
class Foo
def to_ary
[1,2,3]
end
end
Benchmark.ips do |x|
ary = []
100.times { |i| ary << i }
array = [ary]
x.report "Array#flatten" do |i|
i.times { array.flatten }
end
x.report "Array#+" do |i|
obj = Foo.new
i.times { array + obj }
end
end
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c(rb_file_path): [DOC] Note that the pathname returned by this
method can be inaccurate, for instance file gets moved, renamed,
deleted or is created with File::TMPFILE option.
Relates to [Feature #13568]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
"/dev/null" is a common sight for pre-1.9.3-compatible code
targeting *nix systems, so deduplicate it here, as well.
* file.c (Init_File): use fstring for File::NULL
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
"/" and ":" are always statically registered in symbol.c (Init_op_tbl),
and "\n" is a commonly seen in source code.
* file.c (Init_File): fstring on File::SEPARATOR and File::PATH_SEPARATOR
* io.c (Init_IO): fstring on rb_default_rs ("\n")
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_file_join): join using "/" always, not a constant.
and fix the document. [ruby-core:79579] [Bug #13223]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_get_path_check_convert): refine the error message
when the path name contains null byte.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (isADS): add macro to tell if Alternate Data Stream
separator, to distinguish from drive letter.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_default_home_dir): resolve home directory from the
system database when HOME is not set. [Feature #12695]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c: include sys/sysmacros.h for ArchLinux which deprecated
use of major() and minor() in sys/types.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_stat_dev_major, rb_stat_dev_minor): use DEVT2NUM as
well as rdev_major and rdev_minor.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (append_fspath): normalize directory name to be appended
on OS X. [ruby-core:75957] [Ruby trunk Bug#12483]
https://github.com/rails/rails/issues/25303#issuecomment-224834804
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_home_dir_of): return the default home path if the
user name is the current user name, on platforms where struct
pwd is not supported. a temporary measure against
[Bug #12226].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (apply2files): return Fixnum so that callers can just
return it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (apply2files): apply to a VALUE vector instead of a
temporary array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_realpath_internal): no argument conversions since
this internal function does not need to_path and encoding
conversions, not to be affected by the default internal
encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_file_s_split): use rb_file_dirname instead of
rb_file_s_dirname with unused Qnil.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (ruby_is_fd_loadable): now return -1 if loadable but
may block.
* ruby.c (open_load_file): wait to read by the result of
ruby_is_fd_loadable, without fstat.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c, io.c, util.c: prefer rb_syserr_fail with saved errno
over setting errno then call rb_sys_fail, not to be clobbered
potentially and to reduce thread local errno accesses.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
NULL checking is finished Before call of memsize functions.
See r52979.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_stat_wr, rb_stat_ww): call get_stat only once and
reduce checking struct. patch by Yuki Kurihara in
[ruby-core:71949]. [Misc #11789]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* beos: Drop support for BeOS now that Haiku is stable.
[Fix GH-1112]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c: [DOC] add a missing period to File docs, to terminate
the sentence and separate from the next sentence. [Fix GH-1111]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
comparing the file indexes on Windows. designate by kosaki.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Even if S_ISREG() is true, the file may be file on FUSE filesystem
or something. We can't assume O_NONBLOCK is safe.
Moreover, we should wait if the path is point to FIFO. That's
FIFO semantics. GVL should be transparent from ruby script.
Thus, just reopen without O_NONBLOCK for filling the requirements.
[Bug #11060][Bug #11559]
* ruby.c (loadopen_func): new for the above.
* file.c (ruby_is_fd_loadable): new. for checks loadable file type
of not.
* file.c (rb_file_load_ok): use ruby_is_fd_loadble()
* internal.h: add ruby_is_fd_loadble()
* common.mk: now, ruby.o depend on thread.h.
* test/ruby/test_require.rb
(TestRequire#test_loading_fifo_threading_success): new test.
This test successful case that loading from FIFO.
* test/ruby/test_require.rb
(TestRequire#test_loading_fifo_threading_raise): rename from
test_loading_fifo_threading. You souldn't rescue an exception
if you test raise or not.
Moreover, this case should be caught IOError because load(FIFO)
should be blocked until given any input.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_file_expand_path_internal): concatenate converted
string to the result instead of making converted string and
append it.
* string.c (rb_str_cat_conv_enc_opts): from rb_str_conv_enc_opts,
separate function to concatenate with transcoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_str_encode_ospath): prefer encoding index as possible
until rb_encoding is needed.
* file.c (rb_file_expand_path_internal): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_file_load_ok): open in non-blocking mode withoout
releasing GVL. don't care about others than regular files and
directories. [ruby-dev:49272] [Bug #11559]
* ruby.c (load_file_internal): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_str_normalize_ospath): place normalized strings to
the result string directly, to get rid of intermediate objects
and copying.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_file_s_utime): same timespec for same time object.
assume time objects are static.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* encindex.h: separate encoding index constants from internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (rb_readlink): move the declaration.
* ruby.c (dladdr_path): rb_readlink now requires the result
encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_realpath_internal): use filesystem encoding if the
argument is in ASCII encodings.
* win32/file.c (rb_readlink): needs the result encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* win32/win32.c (fchmod): implement by using
SetFileInformationByHandle.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (sys_fail2): show method function names but not
"sys_fail2".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_file_s_extname): [DOC] add an example.
* test/ruby/test_path.rb (test_extname): add tests. [Fix GH-978]
* path starts with dot ('.a.rb')
* path includes dir name ('a/b/d/test.rb')
* path includes dir name and dir name starts with dot
('.a/b/d/test.rb')
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_str_normalize_ospath): skip invalid byte sequence not
to loop infinitely. this case usually does not happen as the
input name should come from real file systems.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* win32/win32.c (stati64_set_inode): get nFilIndexHigh/Low, and set it
to the interval of struct st as inode.
* win32/win32.c (stati64_set_inode_handle): call stati64_set_inode.
* win32/win32.c (rb_w32_fstati64): call stati64_set_inode_handle.
* win32/win32.c (stati64_handle): call stati64_set_inode.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (rb_name_err_mesg_new): new wrapper object before
allocate data area and get rid of potential memory leak.
GC guards are no longer needed.
* file.c (stat_new_0): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* win32/file.c (rb_readlink): move from file.c for better buffer
allocation and the result encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* win32/win32.c (winnt_stat): stat with following symbolic links.
* win32/win32.c (winnt_lstat): rename old winnt_stat, which does
not follow symbolic links.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_file_identical_p): fix handle leak, ensure to close
the handle of the first argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.c (dladdr_path): replace the executable path with symlinked
real path. dladdr(3) on Linux returns the argv[0] as dli_fname
instead of the real path, for a symbol defined in the executable
file itself. [Bug #10776]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_file_expand_path_internal): drop characters ignored
by filesystem on Mac OS X.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.in (XCFLAGS): Add include path for NaCl libraries.
(XLDFLAGS): ditto.
(NACL_LIB_PATH): new stubstitution
* nacl/nacl-config.rb: support NACL_LIB_PATH
* nacl/package.rb: ditto.
* nacl/pepper_main.c: replace old implementations with nacl_io.
* nacl/GNUmakefile.in: link nacl_io to pepper_ruby
* ruby.c (rb_load_file): remove __attribute__((weak)) because the old
override hack was replaced with nacl_io.
* file.c (rb_file_load_ok): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (sys/time.h): include after unistd.h to get rid of
mismatch on struct stat and some system call functions on Linux.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Note: Some of the fixes are for newlib in general but not NaCl-specific.
* include/ruby/intern.h (rb_fd_select): declare struct timeval, or the
struct gets local to the function in C99.
* file.c (#include): add nacl/stat.h for PNaCl.
(utimes): added a declaration for PNaCl.
(stat_atimespec): stat::st_atimensec is long long but
timespec::tv_nsec is long in PNaCl.
(stat_mtimespec, stat_ctimespec): ditto.
(rb_group_member): disable getgroups unless HAVE_GETGROUPS.
(eaccess): unify the fallback to generic defined(USE_GETEUID).
* io.c: include sys/time.h for struct timeval.
(rb_close_before_exec): nothing we can do if F_GETFD is not
available.
(ioctl): pnacl newlib actually doesn't have ioctl.
* process.c (maxgroups): it is used iff
defined(_SC_NGROUPS_MAX) || defined(NGROUPS_MAX) but not
defined(HAVE_GETGROUPS) || defined(HAVE_SETGROUPS).
(obj2gid): fail unless the object is a Fixnum if getgrnam is not
available.
(disable_child_handler_fork_child): sigaction is not available in
PNaCl newlib.
* configure.in (warnflags, strict_warnflags): avoid -ansi for strlcpy.
(rb_cv_gcc_atomic_builtins): also check
__atomic_or_etch because it is used in ruby_atomic.h.
(rb_cv_gcc_sync_builtins): ditto.
(HAVE_GETGRNAM): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.in (RUBY_NACL and others): Supports PNaCl.
* dln.c: replace the old hacky dynamic loading over HTTP with nacl_io.
* file.c: tenatively use access(2) instead of eaccess.
(rb_file_load_ok): weaken with attribute but not by postprocess.
* io.c (socket.h): now NaCl has socket.h
(flock): disable here instead of nacl/ioctl.h
* nacl/GNUmakefile.in (CC, LD, NM, AR, AS, RANLIB, OBJDUMP, OBJCOPY):
respect path to them if they are absolute.
This helps naclports to build ruby in their source tree.
(PROGRAM_NMF, .SUFFIXES): support .pnexe for PNaCl.
(ruby.o, file.o): move the hack to attributes in ruby.c and file.c
* nacl/ioctl.h: removed. move the hack to io.c.
* nacl/nacl-config.rb: support arm, pnacl and others.
* nacl/pepper_main.c: support build in a naclports tree.
* ruby.c (rb_load_file): weaken with attribute but not by postprocess.
The patch is by sbc@google.com and the Native Client Authors.
It is available at:
* 873ca4910a/ports/ruby/nacl.patch
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
cleaned up the rdoc style for this method, more to follow.
Originally reported by Michael Renner [Bug #10067]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
is supported on AIX, HP-UX, and Solaris, by using the value of
struct statvfs.f_basetype.
* configure.in (HAVE_STRUCT_STATVFS_F_BASETYPE): check struct
statvfs.f_basetype which is available on AIX, HP-UX, and Solaris.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e