aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
Commit message (Collapse)AuthorAgeFilesLines
* string.c: move common statementnobu2015-08-221-9/+6
| | | | | | | * 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
* * string.c: Fix documentation for String#slicehsbt2015-08-111-1/+1
| | | | | | [ruby-core:70298][Bug #11427] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: [DOC] Make #end_with? example doc symmetryhsbt2015-08-111-0/+6
| | | | | | 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
* vm.c: frozen_strings in rb_vm_tnobu2015-08-091-16/+4
| | | | | | | * 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
* node.c: NODE_ALLOCA for ALLOCVnobu2015-08-051-16/+0
| | | | | | | * 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
* re.c: fix for wide character encodingsnobu2015-08-031-6/+1
| | | | | | | * 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
* hash.c: move rb_obj_hashnobu2015-07-291-3/+0
| | | | | | * 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
* string.c: empty non-embed casenobu2015-07-291-5/+10
| | | | | | | * 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
* hash.c: fix symbol hashnobu2015-07-291-0/+3
| | | | | | | * 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
* string.c: fill the terminatornobu2015-07-251-5/+13
| | | | | | | * 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
* string.c: remove redundant callnobu2015-07-251-1/+1
| | | | | | | * 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
* string.c: cmp ordersnobu2015-07-251-13/+14
| | | | | | | * 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
* string.c: fstring must not be a shared stringnobu2015-07-241-4/+6
| | | | | | | | * 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
* string.c: pool only bare strings in fstringnobu2015-07-241-6/+40
| | | | | | | | | * 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
* string.c: new string for fake stringnobu2015-07-231-3/+14
| | | | | | | * 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
* string.c: trivial optimizationsnobu2015-07-231-4/+7
| | | | | | | * 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
* string.c: taint flagsnobu2015-07-231-20/+17
| | | | | | | | | * 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
* string.c: str_shared_replacenobu2015-07-231-3/+11
| | | | | | | * 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
* string.c: fix coderange of reversenobu2015-07-221-13/+8
| | | | | | | | * 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
* encoding.h: ENC_CODERANGE_CLEAN_Pnobu2015-07-171-8/+6
| | | | | | | | | | | | | * 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
* string.c: remove redundant callsnobu2015-07-161-1/+1
| | | | | | | | * 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
* string.c: remove redundant callsnobu2015-07-151-2/+2
| | | | | | | | * 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
* string.c: ensure String#freeze resizes internal buffernormal2015-07-061-1/+1
| | | | | | | | | | | 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
* string.c: register_fstringnobu2015-07-061-3/+10
| | | | | | | | | * 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
* string.c (rb_str_justify): use RB_GC_GUARDnormal2015-06-241-1/+3
| | | | | | | 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
* string.c: rb_fstring_cstrnobu2015-06-241-0/+7
| | | | | | | * 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
* socket: allow explicit buffer for recv and recv_nonblocknormal2015-06-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* * string.c: added documentation for character sequence \' with String#subhsbt2015-05-161-0/+3
| | | | | | [Bug #11132][ruby-core:69121][fix GH-900][ci skip] Patch by @shishir127 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* range.c: move String specific codenobu2015-05-151-8/+76
| | | | | | | | | | | * range.c (range_include): call rb_str_include_range_p on String. * string.c (str_upto_each): extract from rb_str_upto. * string.c (rb_str_include_range_p): move String specific code from Range#include? in range.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: all_digits_pnobu2015-05-151-14/+13
| | | | | | | * string.c (all_digits_p): extract duplicate code from rb_str_upto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_crypt): Raise ArgumentError whenglass2015-05-101-2/+1
| | | | | | | | | | string passed to String#crypt contains null. the patch is from jrusnack <jrusnack at redhat.com>. [Bug #10988] [fix GH-853] * test/ruby/test_string.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r50336nobu2015-04-251-1/+1
| | | | | | | * string.c (str_buf_cat): expand later so that the buffer can be larger for further use. [Bug #11080] [Bug #11080] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: expand heapnobu2015-04-171-1/+1
| | | | | | | * string.c (str_buf_cat): expand the heap buffer at making str independent, not only just copying. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: clear NOFREE flag at embeddingnobu2015-04-171-1/+1
| | | | | | | | * string.c (STR_SET_EMBED): clear NOFREE flag at embedding as embedded strings no longer refer static strings. [ruby-core:68436] [Bug #10942] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: check before modifynobu2015-04-041-4/+5
| | | | | | | | * string.c (rb_str_setbyte): check the argument first not to discard shared string and code range unnecessarily until actually changing the contents. pointed out by headius. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: add a comment about RSTRING_FSTR.ko12015-03-181-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: introduce STR_FAKESTR to show string is FAKESTR or not.ko12015-03-171-3/+18
| | | | | | | | | * string.c (STR_SET_SHARED): ignore FAKESTR because only Ruby objects can use write barrier. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: smart chompnobu2015-02-241-5/+7
| | | | | | | | * string.c (chompped_length): enable smart chomp for all non-dummy encoding strings, not only default_rs. [ruby-core:68258] [Bug #10893] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: raise a RegexpErrornobu2015-02-231-1/+1
| | | | | | | * string.c (get_pat_quoted): simply raise a RegexpError, TypeError is never raised. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: proper exceptionnobu2015-02-231-2/+2
| | | | | | | | * string.c (rb_str_split_m): raise ArgumentError at broken string not RegexpError, as Regexp is not involved in. [ruby-core:68229] [Bug #10886] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use rb_funcallvnobu2015-02-161-3/+3
| | | | | | | * use rb_funcallv() for no arguments call instead of variadic rb_funcall(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (str_discard): does not free for STR_NOFREE string.mame2015-02-131-1/+1
| | | | | | | | [Bug #10853][ruby-core:68110] * bootstraptest/test_string.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: [DOC] Specify to_s on subclasses [ci skip]marcandre2015-01-291-1/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: term fillnobu2015-01-261-2/+6
| | | | | | * string.c (str_buf_cat): fill wchar terminator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: use local variablesnobu2015-01-261-7/+14
| | | | | | | * string.c (str_buf_cat): use local variables instead of repeating macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: consider widecharnobu2015-01-261-2/+2
| | | | | | | * string.c (str_make_independent_expand): consider wide char encoding. [Fix GH-821] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: terminate when embeddednobu2015-01-261-0/+1
| | | | | | | * string.c (str_make_independent_expand): terminate String when moved from heap to embedded. [Fix GH-821]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: improve docs for String#<=>. [ruby-core:65399][Feature #10322]ayumin2015-01-041-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: improve docs for String#strip and variations. ↵ayumin2015-01-041-0/+14
| | | | | | [ruby-core:66081][Bug #10476] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: fix coderange for non-endianness stringnobu2014-12-151-2/+9
| | | | | | | | * string.c (rb_enc_str_coderange): dummy wchar, non-endianness encoding string cannot be ascii only. [ruby-core:66835] [Bug #10598] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e