Граф коммитов

1040 Коммитов

Автор SHA1 Сообщение Дата
nobu 85bbacbba2 string.c: consider capacity
* string.c (rb_str_resize): should consider the capacity instead
  of the old length, as pointed out by nagachika.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-12 11:33:12 +00:00
nobu d07a013cf9 string.c: shrink before freezing
* string.c (rb_str_freeze): shrink the buffer before freezing, as
  pointed out by Eric Wong at [ruby-core:63119].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-12 04:28:16 +00:00
nobu b35a6f91d2 string.c: shrink too big buffer
* string.c (rb_str_resize): shrink the buffer even if new length
  is same but it is enough smaller than the capacity.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-12 04:09:26 +00:00
nobu d9e00a7d00 string.c: update rdoc of rb_str_slice_bang()
* string.c (rb_str_slice_bang): [DOC] update return value against
  a fixnum, which has changed because of M17N.  [fix GH-631]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-07 19:52:43 +00:00
nobu f2980e3e20 encoding.h: constify rb_encoding
* include/ruby/encoding.h: constify `rb_encoding` itself, not only
  arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-02 20:23:47 +00:00
nobu 046831094b constify rb_encoding and OnigEncoding
* include/ruby/encoding.h: constify `rb_encoding` arguments.
* include/ruby/oniguruma.h: constify `OnigEncoding` arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-01 22:06:11 +00:00
nobu 950508e9b7 string.c: reset code range
* string.c (rb_str_substr): need to reset code range for shared
  string too, not only copied string.
  [ruby-core:62842] [Bug #9882]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-30 02:33:38 +00:00
nobu 8fb925dfcd string.c: byte offset
* string.c (rb_pat_search): advance by byte offset but not by char
  offset.  [ruby-core:62669] [Bug #9849]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-19 07:29:51 +00:00
nobu 72c773b15d string.c: constify
* string.c (rb_str_index): constify local pointer variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-19 07:06:54 +00:00
naruse df645bf79c * string.c (rb_str_coderange_scan_restartable): coderange is always
ENC_CODERANGE_VALID if the string is ASCII-8BIT and already has a non
  ASCII character.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21 10:15:54 +00:00
naruse 9f2ddef227 * string.c (coderange_scan): remove useless condtion `p < e` after
search_nonascii.

* string.c (rb_str_coderange_scan_restartable): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21 10:15:20 +00:00
naruse 8377e9e435 * string.c (coderange_scan): remove unused logic.
* string.c (rb_str_coderange_scan_restartable): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21 10:14:43 +00:00
nobu 8581ce328d string.c: rename rb_str_splice as rb_str_update
* string.c (rb_str_update): rename rb_str_splice as exported name
  rb_str_update, and make the former an alias macro of the latter.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21 08:31:30 +00:00
nobu 07cad43677 string.c: SHARABLE_SUBSTRING_P
* string.c (SHARABLE_SUBSTRING_P): predicate if substring can be
  shared with the original string.  true if just at the end of the
  original string, for the time being.  all substring will be able to
  be shared in the future.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 15:17:21 +00:00
nobu 609a6ebac5 string.c: share middle of a string
* string.c (rb_str_new_frozen): consider the shared string at
  middle.
* string.c (rb_str_subseq, rb_str_substr, str_byte_substr): share
  middle of a string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 12:48:26 +00:00
nobu 39fe6aa304 string.c: revert r45622
* string.c (str_buf_cat): revert r45622.  broken data can be added
  later.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 08:27:09 +00:00
nobu 46c3749996 string.c: r45621
* string.c (str_buf_cat): revert r45621.  this function does not
  scan appended data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 08:17:44 +00:00
nobu af2228a08d string.c: don't clear coderange at expanding
* string.c (rb_str_modify_expand): like as str_modify_keep_cr,
  don't clear coderange unless broken.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 08:00:04 +00:00
nobu 0ee6aff847 string.c: keep code range
* string.c (str_buf_cat): keep code range if possible.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 07:55:04 +00:00
naruse fb1b9a78b7 * string.c: use uintptr_t instead of VALUE because they are not ruby
object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 06:43:29 +00:00
naruse cbab67a1ac * string.c: check str_strlen's argument, and add comment or
use NULL if simply it uses str's enc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 06:43:11 +00:00
naruse c37ac7ba91 * string.c (str_strlen): use enc_strlen if the coderange is known.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 06:43:08 +00:00
naruse 0ab9abe069 * string.c (enc_strlen): move UTF-8 optimization from str_strlen to
enc_strlen.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 06:42:51 +00:00
nobu a0209e4845 string.c: argument check
* string.c (rb_str_cat_cstr): check the argument as other `_cstr`
  functions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-17 05:23:00 +00:00
nobu 37dffb599d string.c: rb_str_cat_cstr
* string.c (rb_str_cat): make non-buf version main.

* string.c (rb_str_cat_cstr): rename from rb_str_cat2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-17 05:22:57 +00:00
nobu 3784395b8d string.c: alias of rb_str_buf_cat and rb_str_buf_cat2
* string.c (rb_str_cat, rb_str_cat2): make aliases of
  rb_str_buf_cat and rb_str_buf_cat2 respectively.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-17 02:41:36 +00:00
nobu df66229230 string.c: reduce duplicated code
* string.c (rb_str_cat, rb_str_cat2): reduce duplicated code, they
  are same as rb_str_buf_cat and rb_str_buf_cat2 respectively now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-17 02:41:34 +00:00
nobu 982618ed7e string.c: reduce function calls
* 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-14 05:33:42 +00:00
nobu 925cc8ffd0 string.c: keep source code range
* 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-14 05:33:40 +00:00
nobu 2f3b28c682 string.c: clear env self in symbol proc
* 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-12 13:11:11 +00:00
nobu 5c7564c9e2 string.c: remove unnecessary terminator space
* 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-09 03:50:07 +00:00
nobu 68537a4219 string.c: fix capacity
* 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-04-09 03:44:55 +00:00
ktsj e4879afe3e * parse.y (rb_str_dynamic_intern): [DOC] move rdoc from rb_str_intern.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-30 08:10:04 +00:00
nobu 9d1bf5b33a string.c: infect match result
* 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-28 02:28:18 +00:00
nobu 2f14bde88f string.c: backref substitution
* 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-28 02:28:16 +00:00
nobu 2d82342cf2 string.c: unset $~ if unmatch
* 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-28 02:27:14 +00:00
nobu fb3bd78725 string.c: suppress warnings
* 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-27 12:03:36 +00:00
nobu 5752b61d86 string.c: search by rb_str_index
* 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-27 09:58:12 +00:00
nobu 227a5a2aae string.c: mustnot_broken
* 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-27 09:47:03 +00:00
nobu 949f1160d6 string.c: invert flag
* 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-27 03:03:19 +00:00
nari 90b7073842 * parse.y: support Symbol GC. [ruby-trunk Feature #9634]
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-26 04:57:47 +00:00
charliesome a77206582e Stop allocating backref strings within gsub's search loop
* 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-25 23:46:05 +00:00
nobu fc23374f06 [DOC] add links to `Object#hash`
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-14 01:27:43 +00:00
nobu f53c291ab2 string.c: [DOC] rb_str_hash_m
* 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-03-14 01:27:41 +00:00
nobu cc216f9aae adjust indent and style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 07:10:14 +00:00
naruse 0b5685a69b * string.c (sym_find): Add Symbol.find(str), which returns whether given
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-25 16:34:00 +00:00
normal f7cff3a940 string.c (rb_str_format_m): trade volatile for RB_GC_GUARD
* 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-14 09:42:14 +00:00
ko1 1ccaa4756a * internal.h, vm_core.h: move LIKELY/UNLIKELY/UNINITIALIZED_VAR()
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 04:58:00 +00:00
ko1 3889ce2d15 * string.c (rb_str_free): use FL_TEST(str, STR_SHARED) directly
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 04:31:18 +00:00
ko1 38cd45a3cd * internal.h: remove macros STR_NOCAPA and STR_NOCAPA_P().
* 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 04:21:30 +00:00