summaryrefslogtreecommitdiff
path: root/string.c
AgeCommit message (Collapse)Author
2015-11-07string.c: use predefined IDs for minor bloat reductionnormal
* string.c (id_to_s): remove redundant variable (rb_obj_as_string): trade id_to_s for idTo_s (rb_str_equal): replace rb_intern(...) with pre-defined ID (rb_str_cmp_m): ditto (rb_str_match): ditto (str_upto_each): ditto (rb_str_sum): ditto (Init_String): remove id_to_s initialization This leads to a minor size reduction on my x86 (32-bit) system: text data bss dec hex filename 129373 8 32 129413 1f985 string.o-orig 129082 8 8 129098 1f84a string.o git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29* encoding.c (rb_enc_check_str): add for performance.ko1
This function only accept T_STRING (and T_REGEXP). This patch improves performance of a tiny_segmenter benchmark (num=2) 2.54sec -> 2.42sec on my machine. https://github.com/chezou/TinySegmenter.jl/blob/master/benchmark/benchmark.rb * encoding.c: add ENC_DEBUG and ENC_ASSERT() macros. * internal.h: add a decl. of rb_enc_check_str(). * string.c (rb_str_plus): use rb_enc_check_str(). * string.c (rb_str_subpat_set): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29RUBY_DTRACE_CREATE_HOOKnobu
* internal.h (RUBY_DTRACE_CREATE_HOOK): macro to call hook at object creation. * vm.c (rb_source_location, rb_source_loc): retrieve source path and line number at once. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29revert r52336 (commit miss)ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29* gc.c (gc_mark_ptr): remove debug code for #11244.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23* string.c: Added method signature to include hash. It's inconsistencyhsbt
with `gsub` method signature. [ci skip][fix GH-1023] Patch by @danielevans git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-22fix backslash [ci skip]nobu
* string.c (rb_str_tr): [DOC] Escape backslash in String#tr documentation. [Fix GH-1063] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-17string.c: rb_str_cat_conv_enc_optsnobu
* 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
2015-10-15proc.c: proc without envnobu
* proc.c (rb_sym_to_proc): move from string.c and create a Proc with no environments. [ruby-core:71088] [Bug #11594] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-10* import a github pull requestko1
https://github.com/ruby/ruby/pull/1050 by Kazuho Oku <kazuho@natadeco.co>. This pull request has the following commits. * gc.c: reduce # of args to 6 (max. of register args on x86-64) so that the `newobj_of_slowpass` can be called via TCO. * gc.c (newobj_of), string.c (str_duplicate): for performance, the hot functions must be inlined. * gc.c: for performance, preceding arguments of `.*newobj_of.*` must be same, so that the arg registers can be reused in case of TCO. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-07string.c: str_duplicatenobu
* string.c (str_duplicate): move from rb_str_resurrect to short circuit initialization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-07string.c: fix non-embedded stringnobu
* string.c (rb_str_resurrect): fix resurrection of short enough to be embedded but not embedded string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-07string.c: optimize String#timesnobu
* string.c (rb_str_times): optimize for the argument 0 and 1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-07string.c: use raw macronobu
* string.c (str_new_frozen): use raw macro for RString object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-06* string.c (rb_sym_to_proc): renamenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-06vm_args.c: wrap symbol ifuncnobu
* vm_args.c (args_setup_block_parameter): wrap a symbol in ifunc by a proc as a block parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05string.c: optimize rb_str_resurrectnobu
* string.c (rb_str_resurrect): optimize by short circuit to copy hidden string without checking length, encoding and so on. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-01* string.c (rb_sym_proc_call): constifynobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-30proc.c: include symbol namenobu
* proc.c (proc_to_s): include the original symbol name in string form. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-29compile.c: fix performance of strconcatnobu
* compile.c (compile_dstr_fragments): fix performance by omitting the first empty string only for keeping literal encoding if other literals are too. [ruby-core:70930] [Bug #11556] * string.c (rb_str_append_literal): append but keep encoding non US-ASCII. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-20string.c: separate resetting code rangenobu
* string.c (rb_str_setbyte): separate resetting code range by each code range, and remove unnecessary branches. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-16string.c: keep coderangenobu
* string.c (rb_str_setbyte): keep the code range as possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-15encindex.h: ENCINDEXnobu
* 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
2015-08-22string.c: move common statementnobu
* string.c (sym_inspect): move common statement and change variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-11* string.c: Fix documentation for String#slicehsbt
[ruby-core:70298][Bug #11427] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-11* string.c: [DOC] Make #end_with? example doc symmetryhsbt
with #start_with? [fix GH-992][ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-09vm.c: frozen_strings in rb_vm_tnobu
* vm.c (Init_vm_objects, rb_vm_fstring_table): use frozen_strings table in rb_vm_t. [ruby-core:70274] [Bug #11423] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-05node.c: NODE_ALLOCA for ALLOCVnobu
* node.c (rb_alloc_tmp_buffer): use NODE_ALLOCA to mark locations like as builtin alloca. [ruby-core:70251] [Bug #11418] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-03re.c: fix for wide character encodingsnobu
* re.c (rb_memsearch): should match only char boundaries in wide character encodings. [ruby-core:70220] [Bug #11413] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-29hash.c: move rb_obj_hashnobu
* hash.c (rb_obj_hash): move in order to share with rb_any_hash. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-29string.c: empty non-embed casenobu
* string.c (str_buf_cat): consider empty non-embed string case, not to loop infinitely. [ruby-core:70074] [Bug #11383] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-29hash.c: fix symbol hashnobu
* hash.c (rb_sym_hash): return same value as rb_any_hash() of Symbol. [Bug #9381] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-25string.c: fill the terminatornobu
* string.c (str_replace_shared_without_enc): fill the terminator of embedded strings in wide char encodings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-25string.c: remove redundant callnobu
* string.c (str_replace): remove redundant coderage copy as str_replace_shared already copys it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-25string.c: cmp ordersnobu
* string.c (fstring_cmp, rb_str_hash_cmp): compare lengths first, then encodings, and contents at last. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24string.c: fstring must not be a shared stringnobu
* string.c (fstr_update_callback): fstring must not be a shared string, or the content without RSTRING_FSTR may be freed. [ruby-dev:49188] [Bug #11386] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24string.c: pool only bare strings in fstringnobu
* string.c (fstr_update_callback): pool bare strings only. * string.c (rb_fstring): return the original string with sharing a fstring if it has extra attributes, not the fstring itself. [ruby-dev:49188] [Bug #11386] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23string.c: new string for fake stringnobu
* string.c (fstr_update_callback): create new string for fake string, and pool shared target unless substring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23string.c: trivial optimizationsnobu
* string.c (rb_str_new_frozen, str_make_independent_expand): trivial peephole optimizations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23string.c: taint flagsnobu
* include/ruby/ruby.h: add raw FL macros, which assume always the argument object is not a special constant. * internal.h (STR_EMBED_P, STR_SHARED_P): valid only for T_STRING. * string.c: deal with taint flags directly across String instances. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23string.c: str_shared_replacenobu
* string.c (str_shared_replace): split from rb_str_shared_replace without argument check. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-22string.c: fix coderange of reversenobu
* string.c (rb_str_reverse): reversed string is not a substring, and should not set coderange of the original string. [ruby-dev:49189] [Bug #11387] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17encoding.h: ENC_CODERANGE_CLEAN_Pnobu
* include/ruby/encoding.h (ENC_CODERANGE_CLEAN_P): predicate that tells if the coderange is clean, that is 7bit or valid, and no needs to scrub. * re.c (rb_reg_expr_str): use ENC_CODERANGE_CLEAN_P. * string.c (enc_strlen, rb_enc_cr_str_buf_cat, rb_str_scrub): ditto. * string.c (rb_str_enumerate_chars): ditto, and suppress a warning by gcc6. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16string.c: remove redundant callsnobu
* string.c (rb_str_enumerate_lines): do not check if a block is given twice. RETURN_ENUMERATOR includes rb_block_given_p() check which is redundant here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-15string.c: remove redundant callsnobu
* string.c (rb_str_enumerate_bytes, rb_str_enumerate_codepoints): do not check if a block is given twice. RETURN_SIZED_ENUMERATOR includes rb_block_given_p() check which is redundant here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06string.c: ensure String#freeze resizes internal buffernormal
rb_str_freeze may resize oversized buffers to save memory, so favor it over rb_obj_freeze. This is useful because IO methods do not prematurely shrink buffers, as they are likely to be overwritten with full data. * string.c (Init_String): use rb_str_freeze for String#freeze git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06string.c: register_fstringnobu
* string.c (register_fstring): separate registration from rb_fstring(). * string.c (rb_fstring_new): skip argument checks in rb_fstring(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-24string.c (rb_str_justify): use RB_GC_GUARDnormal
See doc/extension.rdoc for justification using RB_GC_GUARD instead of volatile. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-24string.c: rb_fstring_cstrnobu
* string.c (rb_fstring_cstr): new function to make a fstring from a string literal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-15socket: allow explicit buffer for recv and recv_nonblocknormal
This reduces GC overhead and makes the API more consistent with IO#read and IO#read_nonblock. * ext/socket/basicsocket.c (bsock_recv): document outbuf * ext/socket/unixsocket.c (unix_recvfrom): ditto * ext/socket/init.c (rsock_strbuf, recvfrom_locktmp): new functions (rsock_s_recvfrom): support destination buffer as 3rd arg (rsock_s_recvfrom_nonblock): ditto * string.c (rb_str_locktmp_ensure): export for internal ext * test/socket/test_nonblock.rb: test recv_nonblock * test/socket/test_unix.rb: test recv [ruby-core:69543] [Feature #11242] Benchmark results: user system total real alloc 0.130000 0.280000 0.410000 ( 0.420656) extbuf 0.100000 0.220000 0.320000 ( 0.318708) -------------------8<-------------------- require 'socket' require 'benchmark' nr = 100000 msg = ' ' * 16384 size = msg.bytesize buf = ' ' * size UNIXSocket.pair(:DGRAM) do |a, b| Benchmark.bmbm do |x| x.report('alloc') do nr.times do b.send(msg, 0) a.recv(size, 0) end end x.report('extbuf') do nr.times do b.send(msg, 0) a.recv(size, 0, buf) end end end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e