summaryrefslogtreecommitdiff
path: root/string.c
AgeCommit message (Collapse)Author
2014-04-14string.c: reduce function callsnobu
* string.c (rb_enc_cr_str_buf_cat): reduce invariant function calls of rb_enc_from_index. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-14string.c: keep source code rangenobu
* string.c (rb_enc_cr_str_buf_cat): keep code range of the source string even if code range of the destination string is unknown. no reason to the former is affected by the latter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-12string.c: clear env self in symbol procnobu
* string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear caller's self which is useless, so that it can get collected. [Fixes GH-592] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-09string.c: remove unnecessary terminator spacenobu
* string.c (str_buf_cat): remove unnecessary terminator space, since the capacity does not include its length but RESIZE_CAPA() considers it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-09string.c: fix capacitynobu
* string.c (str_buf_cat): should round up the capacity by 4KiB, but not number of rooms. [ruby-core:61886] [Bug #9709] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-30* parse.y (rb_str_dynamic_intern): [DOC] move rdoc from rb_str_intern.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-28string.c: infect match resultnobu
* string.c (rb_pat_search): match result should be infected by the pattern. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-28string.c: backref substitutionnobu
* re.c (rb_reg_regsub): allow nil regexp for string matching. * string.c (rb_str_sub_bang, str_gsub): make substitution if replacement string has backref escapes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-28string.c: unset $~ if unmatchnobu
* string.c (rb_pat_search): unset $~ if the last match failed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-27string.c: suppress warningsnobu
* string.c (rb_str_sub_bang, str_gsub): initialize conditionally assigned variables to suppress maybe-uninitialized warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-27string.c: search by rb_str_indexnobu
* re.c (match_regexp): set regexp for MatchData from string. * re.c (rb_backref_set_string): create MatchData from string and set backref. * string.c (rb_pat_search, rb_str_sub, rb_str_sub_bang, str_gsub), (scan_once, rb_str_scan, rb_str_partition): use rb_str_index instead of rb_reg_search() when pattern is a String. based on the patch by Sam Rawlins <sam.rawlins@gmail.com> [Fixes GH-579] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-27string.c: mustnot_brokennobu
* string.c (mustnot_broken): extract function to reject invalid byte sequence, from rb_str_split_m(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-27string.c: invert flagnobu
* string.c (str_gsub): invert and rename `str_replace` flag as `need_backref`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26* parse.y: support Symbol GC. [ruby-trunk Feature #9634]nari
See this ticket about Symbol GC. * include/ruby/ruby.h: Declare few functions. * rb_sym2id: almost same as old SYM2ID but support dynamic symbols. * rb_id2sym: almost same as old ID2SYM but support dynamic symbols. * rb_sym2str: almost same as `rb_id2str(SYM2ID(sym))` but not pin down a dynamic symbol. Declare a new struct. * struct RSymbol: represents a dynamic symbol as object in Ruby's heaps. Add few macros. * STATIC_SYM_P: check a static symbol. * DYNAMIC_SYM_P: check a dynamic symbol. * RSYMBOL: cast to RSymbol * gc.c: declare RSymbol. support T_SYMBOL. * internal.h: Declare few functions. * rb_gc_free_dsymbol: free up a dynamic symbol. GC call this function at a sweep phase. * rb_str_dynamic_intern: convert a string to a dynamic symbol. * rb_check_id_without_pindown: not pinning function. * rb_sym2id_without_pindown: ditto. * rb_check_id_cstr_without_pindown: ditto. * string.c (Init_String): String#intern and String#to_sym use rb_str_dynamic_intern. * template/id.h.tmpl: use LSB of ID as a flag for determining a static symbol, so we shift left other ruby_id_types. * string.c: use rb_sym2str instead `rb_id2str(SYM2ID(sym))` to avoid pinning. * load.c: use xx_without_pindown function at creating temporary ID to avoid pinning. * object.c: ditto. * sprintf.c: ditto. * struct.c: ditto. * thread.c: ditto. * variable.c: ditto. * vm_method.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25Stop allocating backref strings within gsub's search loopcharliesome
* internal.h: add prototype for rb_reg_search0 * re.c: rename rb_reg_search to rb_reg_search0, add set_backref_str argument to allow callers to indicate that they don't require the backref string to be allocated * string.c: don't allocate backref str if replacement string is provided Closes GH-578. [Bug #9676] [ruby-core:61682] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-14[DOC] add links to `Object#hash`nobu
add links to `Object#hash` to each #`hash` methods rdocs. [Fixes GH-567] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-14string.c: [DOC] rb_str_hash_mnobu
* string.c (rb_str_hash_m): [DOC] hash value depends on the encoding too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27adjust indent and stylenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-25* string.c (sym_find): Add Symbol.find(str), which returns whether givennaruse
string is defined as symbol or not. [Feature #7854] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-14string.c (rb_str_format_m): trade volatile for RB_GC_GUARDnormal
* string.c (rb_str_format_m): trade volatile for RB_GC_GUARD RB_GC_GUARD meaning is clear and has better code generation. [ruby-core:60688] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05* internal.h, vm_core.h: move LIKELY/UNLIKELY/UNINITIALIZED_VAR()ko1
macros from vm_core.h to internal.h. * string.c: remove dependency to "vm_core.h". * common.mk: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05* string.c (rb_str_free): use FL_TEST(str, STR_SHARED) directlyko1
because str is not embed. * string.c (str_replace): remove `FL_SET(str, STR_SHARED)' line because STR_SET_SHARED() set STR_SHARED. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05* internal.h: remove macros STR_NOCAPA and STR_NOCAPA_P().ko1
* string.c (rb_str_resize): remove `STR_SET_NOEMBED(str)' because str_make_independent_expand() set NOEMBED flag. * string.c (rb_str_resize): remove `STR_NOCAPA_P(str)' check because `str' is independent (not shared). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05* string.c: refactoring, especially about string flags.ko1
* string.c (STR_UNSET_NOCAPA): removed. Use FL_UNSET() with STR_SHARED. * string.c (rb_str_capacity): check STR_SHARED directly beacuse it is not a embed string. * string.c (rb_str_modify_expand): ditto. * string.c (rb_str_shared_replace): use STR_SET_SHARED(). * string.c (str_make_independent_expand): remove STR_UNSET_NOCAPA() because `str' is not shared string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05* string.c (RESIZE_CAPA): should not resize shared string.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05* string.c (rb_str_new_frozen): refactoring code.ko1
* Move code from str_new_frozen_with_klass() (and remove it) * `aux.shared' should not be 0 for STR_SHARED strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-04* string.c: use long allocator names instead of numberedko1
allocator names. * rb_str_new2 -> rb_str_new_cstr * rb_str_new4 -> rb_str_new_frozen * rb_str_new5 -> rb_str_new_with_class * str_new3 -> str_new_shared * str_new4 -> str_new_frozen_with_klass git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-04* string.c: use STR_SHARED instead of ELTS_SHARED.ko1
(same value, but more clear meaning) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-04* string.c: remvoe STR_ASSOC related code.ko1
By r44804, string objects can not have STR_ASSOC flag. * internal.h: ditto. * ext/objspace/objspace_dump.c (dump_object): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-04pack.c: use ivar for associated objectsnobu
* pack.c (str_associate, str_associated): keep associated objects in an instance variables, instead of in the internal structure. * string.c (rb_str_associate, rb_str_associated): deprecate. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-04string.c: enable capacity when setting capanobu
* string.c (rb_str_modify_expand): enable capacity and disable assocation with packed objects when setting capa, so that pack("p") string fails to unpack properly after modified. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-15string.c: respect BOMnobu
* string.c (get_encoding): respect BOM on pseudo encodings. [ruby-dev:47895] [Bug #9415] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-15string.c: use actual encodingsnobu
* string.c (get_actual_encoding): get actual encoding according to the BOM if exists. * string.c (rb_str_inspect): use according encoding, instead of pseudo encodings, UTF-{16,32}. [ruby-core:59757] [Bug #8940] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20* include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN intoko1
RB_OBJ_WRITE and RB_OBJ_WRITTEN. * array.c, class.c, compile.c, hash.c, internal.h, iseq.c, proc.c, process.c, re.c, string.c, variable.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_insnhelper.h, vm_method.c: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08parse.y: use rb_fstring() for strings stored in the symbol tabletmm1
* parse.y (register_symid_str): use fstrings in symbol table [Bug #9171] [ruby-core:58656] * parse.y (rb_id2str): ditto * string.c (rb_fstring): create frozen_strings on first usage. this allows rb_fstring() calls from the parser (before cString is created) * string.c (fstring_set_class_i): set klass on fstrings generated before cString was defined * string.c (Init_String): convert frozen_strings table to String objects after boot * ext/-test-/symbol/type.c (bug_sym_id2str): expose rb_id2str() * test/-ext-/symbol/test_type.rb (module Test_Symbol): verify symbol table entries are fstrings git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05* string.c (rb_str_scrub): [DOC] add param str.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-04string.c: fix declaration-after-statementnobu
* string.c (fstr_update_callback): move a variable declaration since ISO C90 forbids mixed declarations and code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-04* string.c (fstr_update_callback): Improve implementation in r43968tmm1
based on feedback from @nagachika. In the existing case, we can return ST_STOP to prevent any hash modification. In the !existing case, set both key and value to the fstr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03* string.c (rb_fstring): Use st_update instead of st_lookup +tmm1
st_insert. * string.c (fstr_update_callback): New callback for st_update. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-28* string.c (rb_fstring): fstrings should be ELTS_SHARED.ko1
If we resurrect dying objects (non-marked, but not swept yet), pointing shared string can be collected. To avoid such issue, fstrings (recorded to fstring_table) should not be ELTS_SHARED (should not have a shared string). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-26* compile.c: Use rb_fstring() to de-duplicate string literals in code. ↵tmm1
[ruby-core:58599] [Bug #9159] [ruby-core:54405] * iseq.c (prepare_iseq_build): De-duplicate iseq labels and source locations. * re.c (rb_reg_initialize): Use rb_fstring() for regex string. * string.c (rb_fstring): Handle non-string and already-fstr arguments. * vm_eval.c (eval_string_with_cref): De-duplicate eval source filename. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-26string.c: fix memsize of frozen shared stringnobu
* string.c (str_new4): copy the original capacity so that memsize of frozen shared string returns correct size. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-25* internal.h: do not use ruby_sized_xrealloc() and ruby_sized_xfree()ko1
if HAVE_MALLOC_USABLE_SIZE (or _WIN32) is defined. We don't need these function if malloc_usable_size() is available. * gc.c: catch up this change. * gc.c: define HAVE_MALLOC_USABLE_SIZE on _WIN32. * array.c (ary_resize_capa): do not use ruby_sized_xfree() with local variable to avoid "unused local variable" warning. This change only has few impact. * string.c (rb_str_resize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-19* gc.c (rb_gc_resurrect): added.ko1
rb_fstring() used rb_gc_mark() to avoid freeing used string. However, rb_gc_mark() set mark bit *and* pushes mark_stack. rb_gc_resurrect() does only set mark bit if it is before sweeping. * string.c (rb_fstring): use rb_gc_resurrect. * internal.h: add decl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-17string.c: constifynobu
* string.c (tr_find): constify argument table. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-11* internal.h: move common string/hash flags to include file.tmm1
* ext/objspace/objspace_dump.c: remove flags shared above. * hash.c: ditto. * string.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09* compile.c (iseq_compile_each): emit opt_str_freeze if the #freezecharliesome
method is called on a static string literal with no arguments. * defs/id.def (firstline): add freeze so idFreeze is available * insns.def (opt_str_freeze): add opt_str_freeze instruction which pushes a frozen string literal without allocating a new object if String#freeze is not overriden * string.c (Init_String): define String#freeze * vm.c (vm_init_redefined_flag): define BOP_FREEZE on String class as a basic operation * vm_insnhelper.h: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01string.c: fix typonobu
* string.c (rb_str_scrub): fix typo, should yield invalid byte sequence to be scrubbed. reported by znz at IRC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01string.c: export rb_str_scrubnobu
* string.c (rb_str_scrub): export with fixed length arguments, and allow nil as replacement string instead of omitting. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-17* string.c (STR_HEAP_SIZE): includes TERM_LEN(str).ko1
* string.c (rb_str_memsize): use STR_HEAP_SIZE(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e