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

928 Коммитов

Автор SHA1 Сообщение Дата
mame f0f13cff72 * hash.c (rb_hash_update): fix indent
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-19 02:10:58 +00:00
mame bfbf9bd6d3 * hash.c (rb_hash_update): remove a meticulous explanation
As per Marc-Andre's comment.  [Refs GH-1951]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-19 02:07:33 +00:00
mame 085f5ef957 * hash.c (rb_hash_merge): Accepts zero or more hashes as arguments
Hash#merge, merge!, and update could merge exactly two hashes.
Now, they accepts zero or more hashes as arguments so that it can merge
hashes more than two.

This patch was created by Koki Ryu <liukoki@gmail.com> at Ruby Hack
Challenge #5.  Thank you!
[ruby-core:88970] [Feature #15111] [Fix GH-1951]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-19 01:59:26 +00:00
nobu 384fda18b8 warn unused blocks with Enumerable#all? any? one? none?
[Fix GH-1953]

From: Koji Onishi <fursich0@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-13 11:10:24 +00:00
nobu 490fbc4c85 hash.c: env block size limit on Windows
* hash.c (ruby_setenv): do not check environment block size.
  c.f. https://msdn.microsoft.com/en-us/library/windows/desktop/ms682653(v=vs.85).aspx
  Starting with Windows Vista and Windows Server 2008, there is no
  technical limitation on the size of the environment block.
  [ruby-core:88400] [Bug #14979]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-11 13:18:55 +00:00
tenderlove efee3033b5 Include Hash#size in the examples
Both methods Hash#length and Hash#size share the same source code in
Ruby, but they also share the same documentation. Now when you look at
the documentation of Hash#size you only see examples for Hash#length,
which is confusing. This commit includes Hash#size in the examples and
also remarks that both methods are equivalent to each other.

Co-authored-by: Alberto Almagro <alberto.almagro@rakuten.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-27 17:28:41 +00:00
nobu 5ad205b81d renamed ruby_tz_update as ruby_tz_uptodate_p
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-19 11:22:03 +00:00
nobu 4bc1669127 reduce tzset
* time.c (rb_localtime_r): call tzset() only after TZ environment
  variable is changed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-18 10:30:41 +00:00
ktsj d62b7e133e [DOC] Add call signature for {Array,Hash}#any?
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-23 04:57:49 +00:00
shyouhei 841d5ae80e rb_ary_dig, rb_hash_dig: nobody is using them outside.
mark them static.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-08 09:09:12 +00:00
nobu 9760a7f905 Add slice method to ENV like Hash#slice
[Feature #14559]

From:    Benoit Tigeot <benoit@hopsandfork.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-19 05:55:42 +00:00
eregon b1a8c64483 Add a new #filter alias for #select
* In Enumerable, Enumerator::Lazy, Array, Hash and Set
  [Feature #13784] [ruby-core:82285]
* Share specs for the various #select#select! methods and
  reuse them for #filter/#filter!.
* Add corresponding filter tests for select tests.
* Update NEWS.

[Fix GH-1824]

From: Alexander Patrick <adp90@case.edu>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-25 13:52:07 +00:00
nobu 96db72ce38 [DOC] missing docs at toplevel
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-23 02:18:52 +00:00
k0kubun ed935aa5be mjit_compile.c: merge initial JIT compiler
which has been developed by Takashi Kokubun <takashikkbn@gmail> as
YARV-MJIT. Many of its bugs are fixed by wanabe <s.wanabe@gmail.com>.

This JIT compiler is designed to be a safe migration path to introduce
JIT compiler to MRI. So this commit does not include any bytecode
changes or dynamic instruction modifications, which are done in original
MJIT.

This commit even strips off some aggressive optimizations from
YARV-MJIT, and thus it's slower than YARV-MJIT too. But it's still
fairly faster than Ruby 2.5 in some benchmarks (attached below).

Note that this JIT compiler passes `make test`, `make test-all`, `make
test-spec` without JIT, and even with JIT. Not only it's perfectly safe
with JIT disabled because it does not replace VM instructions unlike
MJIT, but also with JIT enabled it stably runs Ruby applications
including Rails applications.

I'm expecting this version as just "initial" JIT compiler. I have many
optimization ideas which are skipped for initial merging, and you may
easily replace this JIT compiler with a faster one by just replacing
mjit_compile.c. `mjit_compile` interface is designed for the purpose.

common.mk: update dependencies for mjit_compile.c.

internal.h: declare `rb_vm_insn_addr2insn` for MJIT.

vm.c: exclude some definitions if `-DMJIT_HEADER` is provided to
compiler. This avoids to include some functions which take a long time
to compile, e.g. vm_exec_core. Some of the purpose is achieved in
transform_mjit_header.rb (see `IGNORED_FUNCTIONS`) but others are
manually resolved for now. Load mjit_helper.h for MJIT header.
mjit_helper.h: New. This is a file used only by JIT-ed code. I'll
refactor `mjit_call_cfunc` later.
vm_eval.c: add some #ifdef switches to skip compiling some functions
like Init_vm_eval.

win32/mkexports.rb: export thread/ec functions, which are used by MJIT.

include/ruby/defines.h: add MJIT_FUNC_EXPORTED macro alis to clarify
that a function is exported only for MJIT.

array.c: export a function used by MJIT.
bignum.c: ditto.
class.c: ditto.
compile.c: ditto.
error.c: ditto.
gc.c: ditto.
hash.c: ditto.
iseq.c: ditto.
numeric.c: ditto.
object.c: ditto.
proc.c: ditto.
re.c: ditto.
st.c: ditto.
string.c: ditto.
thread.c: ditto.
variable.c: ditto.
vm_backtrace.c: ditto.
vm_insnhelper.c: ditto.
vm_method.c: ditto.

I would like to improve maintainability of function exports, but I
believe this way is acceptable as initial merging if we clarify the
new exports are for MJIT (so that we can use them as TODO list to fix)
and add unit tests to detect unresolved symbols.
I'll add unit tests of JIT compilations in succeeding commits.

Author: Takashi Kokubun <takashikkbn@gmail.com>
Contributor: wanabe <s.wanabe@gmail.com>

Part of [Feature #14235]

---

* Known issues
  * Code generated by gcc is faster than clang. The benchmark may be worse
    in macOS. Following benchmark result is provided by gcc w/ Linux.
  * Performance is decreased when Google Chrome is running
  * JIT can work on MinGW, but it doesn't improve performance at least
    in short running benchmark.
  * Currently it doesn't perform well with Rails. We'll try to fix this
    before release.

---

* Benchmark reslts

Benchmarked with:
Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores

- 2.0.0-p0: Ruby 2.0.0-p0
- r62186: Ruby trunk (early 2.6.0), before MJIT changes
- JIT off: On this commit, but without `--jit` option
- JIT on: On this commit, and with `--jit` option

** Optcarrot fps

Benchmark: https://github.com/mame/optcarrot

|         |2.0.0-p0 |r62186   |JIT off  |JIT on   |
|:--------|:--------|:--------|:--------|:--------|
|fps      |37.32    |51.46    |51.31    |58.88    |
|vs 2.0.0 |1.00x    |1.38x    |1.37x    |1.58x    |

** MJIT benchmarks

Benchmark: https://github.com/benchmark-driver/mjit-benchmarks
(Original: https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch/MJIT-benchmarks)

|           |2.0.0-p0 |r62186   |JIT off  |JIT on   |
|:----------|:--------|:--------|:--------|:--------|
|aread      |1.00     |1.09     |1.07     |2.19     |
|aref       |1.00     |1.13     |1.11     |2.22     |
|aset       |1.00     |1.50     |1.45     |2.64     |
|awrite     |1.00     |1.17     |1.13     |2.20     |
|call       |1.00     |1.29     |1.26     |2.02     |
|const2     |1.00     |1.10     |1.10     |2.19     |
|const      |1.00     |1.11     |1.10     |2.19     |
|fannk      |1.00     |1.04     |1.02     |1.00     |
|fib        |1.00     |1.32     |1.31     |1.84     |
|ivread     |1.00     |1.13     |1.12     |2.43     |
|ivwrite    |1.00     |1.23     |1.21     |2.40     |
|mandelbrot |1.00     |1.13     |1.16     |1.28     |
|meteor     |1.00     |2.97     |2.92     |3.17     |
|nbody      |1.00     |1.17     |1.15     |1.49     |
|nest-ntimes|1.00     |1.22     |1.20     |1.39     |
|nest-while |1.00     |1.10     |1.10     |1.37     |
|norm       |1.00     |1.18     |1.16     |1.24     |
|nsvb       |1.00     |1.16     |1.16     |1.17     |
|red-black  |1.00     |1.02     |0.99     |1.12     |
|sieve      |1.00     |1.30     |1.28     |1.62     |
|trees      |1.00     |1.14     |1.13     |1.19     |
|while      |1.00     |1.12     |1.11     |2.41     |

** Discourse's script/bench.rb

Benchmark: https://github.com/discourse/discourse/blob/v1.8.7/script/bench.rb

NOTE: Rails performance was somehow a little degraded with JIT for now.
We should fix this.
(At least I know opt_aref is performing badly in JIT and I have an idea
 to fix it. Please wait for the fix.)

*** JIT off
Your Results: (note for timings- percentile is first, duration is second in millisecs)

categories_admin:
  50: 17
  75: 18
  90: 22
  99: 29
home_admin:
  50: 21
  75: 21
  90: 27
  99: 40
topic_admin:
  50: 17
  75: 18
  90: 22
  99: 32
categories:
  50: 35
  75: 41
  90: 43
  99: 77
home:
  50: 39
  75: 46
  90: 49
  99: 95
topic:
  50: 46
  75: 52
  90: 56
  99: 101

*** JIT on
Your Results: (note for timings- percentile is first, duration is second in millisecs)

categories_admin:
  50: 19
  75: 21
  90: 25
  99: 33
home_admin:
  50: 24
  75: 26
  90: 30
  99: 35
topic_admin:
  50: 19
  75: 20
  90: 25
  99: 30
categories:
  50: 40
  75: 44
  90: 48
  99: 76
home:
  50: 42
  75: 48
  90: 51
  99: 89
topic:
  50: 49
  75: 55
  90: 58
  99: 99

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-04 11:22:28 +00:00
mrkn 52bb93c25a hash.c: support key swapping in Hash#transform_keys!
* hash.c (rb_hash_transform_keys_bang): support key swapping in
  Hash#transform_keys!
  [Bug #14380] [ruby-core:84951]

* test/ruby/test_hash.rb (test_transform_keys_bang):
  add assertions for this change

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-26 01:33:45 +00:00
nobu e9cb552ec9 internal.h: remove dependecy on ruby/encoding.h
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 06:24:11 +00:00
normal fc939f6697 hash literal deduplicates like Hash#[]=
From: Eric Wong <e@80x24.org>

* hash.c (rb_hash_key_str): new function
  (hash_aset_str): use rb_hash_key_str
* internal.h: add rb_hash_key_str
* st.c (st_stringify): use rb_hash_key_str
* test/ruby/test_hash.rb (test_NEWHASH_fstring_key): dynamic key
  [ruby-core:84554] [Feature #14258]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-30 00:00:23 +00:00
nobu baa53f625d hash.c: prime2
* hash.c (prime2): turned into a uint32_t prime, as the lower
  32bits, non-prime part only was used always.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-25 12:41:52 +00:00
nobu ce52dfde9c hash.c: use uint128_t
* hash.c (mult_and_mix): use uint128_t instead of __uint128_t.
  [ruby-core:84438] [Bug #14231]

From: Nobuyoshi Nakada <nobu@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-25 12:32:10 +00:00
nobu 8880af9a3b Use UINT128_T support flag from configure
Current check for __uint128_t in hash.c is not valid, since it ignores
compilers other than gcc. We hit this on lcc on e2k platform.

Configure script properly checks from 128-bit data types support and
sets HAVE_UINT128_T accordingly. This approach is already used within
ruby at bignum.c, random.c, etc.

Probably hash.c is an overlooked remnant of old days. This patch fixes
this.

[ruby-core:84438] [Bug #14231] [Fix GH-1781]
From: Andrew Savchenko <bircoph@altlinux.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-25 12:32:09 +00:00
usa 52220154a8 force hash values fixable
* include/ruby/ruby.h (RB_ST2FIX): force fixable on LLP64 environment.

* hash.c (any_hash): ditto.
  [ruby-core:84395] [Bug #14218]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 08:52:11 +00:00
marcandre a9770bac63 Add case equality arity to Enumerable#all?, any?, none? and one?,
and specialized Array#any? and Hash#any?
Based on patch by D.E. Akers [#11286]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-10 22:36:28 +00:00
mame 0a6816ecd7 Revamp method coverage to support define_method
Traditionally, method coverage measurement was implemented by inserting
`trace2` instruction to the head of method iseq.  So, it just measured
methods defined by `def` keyword.

This commit drastically changes the measuring mechanism of method
coverage; at `RUBY_EVENT_CALL`, it keeps a hash from rb_method_entry_t*
to runs (i.e., it counts the runs per method entry), and at
`Coverage.result`, it creates the result hash by enumerating all
`rb_method_entry_t*` objects (by `ObjectSpace.each_object`).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05 07:16:42 +00:00
stomar 6f33cde636 hash.c: improve docs for Hash#slice
* hash.c: [DOC] clarify description for Hash#slice and remove
  a sentence that might suggest that the receiver is modified;
  improve example to also include a case where a hash with
  several elements is returned.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 20:17:04 +00:00
nobu 6b818dd961 common conversion functions
* array.c (rb_to_array_type): make public to share common code
  internally.

* hash.c (rb_to_hash_type): make public to share common code
  internally.

* symbol.c (rb_to_symbol_type): make public to share common code
  internally.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26 07:23:23 +00:00
kazu a48704106d Update doc of Hash#slice [ci skip]
- Add arguments to call-seq
- Add sample of multiple keys
- Add sample: hash does not contain key

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 07:01:57 +00:00
glass 2ec29f3f7f hash.c: optimize Hash#compare_by_identity
hash.c (rb_hash_compare_by_id): avoid unnecessary allocation of st_table.
formerly, st_table created in rb_hash_modify() was not used and replaced immediately.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 00:57:46 +00:00
glass f1f7b51d73 Add arity check into Hash#flatten
* hash.c (rb_hash_flatten): add arity check

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 00:38:05 +00:00
hsbt ec4141f183 Added sample code of merge! method in hash.c.
https://github.com/ruby/ruby/pull/1652

  Patch by @selmertsx [fix GH-1652]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 13:40:12 +00:00
glass 6c50bdda0b hash.c: Add Hash#slice
* hash.c (rb_hash_slice): add Hash#slice [Feature #8499]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 06:08:33 +00:00
glass f5740d18bf Revert "vm_eval.c: add rb_yield_assoc_or_values()"
This reverts commit r60095 to prevent performance degradation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-02 07:51:27 +00:00
glass 7ae65b24c2 vm_eval.c: add rb_yield_assoc_or_values()
The new function rb_yield_assoc_or_values() will reduce branching.

* vm_eval.c: add rb_yield_assoc_or_values()

* internal.h: ditto

* hash.c: use rb_yield_assoc_or_values()

* struct.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-02 05:29:11 +00:00
glass 8875e0ca4a use rb_hash_new_with_size()
* hash.c: use rb_hash_new_with_size().

* marshal.c: ditto

* struct.c: ditto

* vm_args.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-01 04:26:25 +00:00
glass c879b60152 hash.c: remove special treatments on deletion
st.c was improved in r56650 that it permits deletion during iteration.
In this commit, special treatments for previous implementation are
removed.

* hash.c: don't use *_check and *_safe functions in st.c

* internal.h: remove HASH_DELETED flag

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-30 11:58:33 +00:00
nobu 13f5dcb9f2 error.c: KeyError#receiver and KeyError#key
* error.c: new method KeyError#receiver and KeyError#key.
  [Feature #12063]

* hash.c: make KeyError object with receiver and key.

* sprintf.c: ditto.

Author:    ksss <co000ri@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-18 08:05:53 +00:00
shyouhei 0eb7359cc7 add rb_hash_new_with_size()
Sometimes, size of a hash can be calcluated a priori.  By providing
such info to the constructor we can avoid unnecessary internal re-
allocations.  This can boost for instance creation of hash literals.
[Bug #13861]

Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-05 04:48:19 +00:00
nobu 0118b98545 Update Hash#compact! documentation [ci skip]
* hash.c (rb_hash_compact_bang): [DOC] update the case if no
  changes were made.  [ruby-core:82591] [Bug #13855] [Fix GH-1692]

Author:    Lucas Buchala <lucasbuchala@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-02 01:08:27 +00:00
kazu 14638d8547 [DOC] Fix typo in rdoc of `transform_values!` [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-28 11:20:08 +00:00
nobu f9d5843fd9 hash.c: refactor env_enc_str_new
* hash.c (env_enc_str_new): convert to the expected encoding
  without intermediate string, and set econv flags if default
  internal encoding is set too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-30 02:56:30 +00:00
normal 0493b1ce3a revert r59359, r59356, r59355, r59354
These caused numerous CI failures I haven't been able to
reproduce [ruby-core:82102]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-19 01:35:04 +00:00
normal d04c085b3c hash: keep fstrings of tainted strings for string keys
The same hash keys may be loaded from tainted data sources
frequently (e.g. parsing headers from socket or loading
YAML data from a file).  If a non-tainted fstring already
exists (because the application expects the hash key),
cache and deduplicate the tainted version in the new
tainted_frozen_strings table.

For non-embedded strings, this also allows sharing with the
underlying malloc-ed data.

* vm_core.h (rb_vm_struct): add tainted_frozen_strings
* vm.c (ruby_vm_destruct): free tainted_frozen_strings
  (Init_vm_objects): initialize tainted_frozen_strings
  (rb_vm_tfstring_table): accessor for tainted_frozen_strings
* internal.h: declare rb_fstring_existing, rb_vm_tfstring_table
* hash.c (fstring_existing_str): remove (moved to string.c)
  (hash_aset_str): use rb_fstring_existing
* string.c (rb_fstring_existing): new, based on fstring_existing_str
  (tainted_fstr_update): new
  (rb_fstring_existing0): new, based on fstring_existing_str
  (rb_tainted_fstring_existing): new, special case for tainted strings
  (rb_str_free): delete from tainted_frozen_strings table
* test/ruby/test_optimization.rb (test_hash_reuse_fstring): new test
  [ruby-core:82012] [Bug #13737]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-18 02:29:59 +00:00
rhe 677751e1bc hash.c: fix possible crash in Hash#transform_keys!
Fix up r59328. It is possible that the given block abuses
ObjectSpace.each_object to shrink the temporary array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-14 09:41:05 +00:00
mrkn 1405111722 hash.c: Add Hash#transform_keys and Hash#transform_keys!
* hash.c (transform_keys_i, rb_hash_transform_keys): Add Hash#transform_keys.
  [Feature #13583] [ruby-core:81290]

* hash.c (rb_hash_transform_keys_bang): Add Hash#transform_keys!.
  [Feature #13583] [ruby-core:81290]

* test/ruby/test_hash.rb: Add tests for above changes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-14 06:44:00 +00:00
ko1 5168fb54e3 tainted string should be tainted.
* hash.c (hash_aset_str): create frozen string for tainted objects.
  (should not use fsting table on this case).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-11 07:42:27 +00:00
nobu f1fe99b1be hash.c: prefer value cast to pointer cast
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-10 00:41:21 +00:00
normal e205304a3e Hash#[]= deduplicates string keys if (and only if) fstring exists
In typical applications, hash entries are read after being
written to.  Blindly writing to hashes which are never read
makes little sense. So, for any hash which is read from, an
fstring entry for the key should already exist for the key.

We no longer blindly create fstrings if the code is blindly
setting random hash keys, preventing the performance regression
in the reverted r43870.

Regarding <https://bugs.ruby-lang.org/issues/9188>, this has a
minimum impact on the bm_so_k_nucleotide where hash keys are set
and not reused, performance is within 1-2% of existing cases.

* hash.c: #include gc.h for rb_objspace_garbage_object_p
  (hash_aset_str): do read-only check of fstring table and
  reuse fstring if it exists and is still alive (not garbage)
  [ruby-core:81942] [Feature #13725]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-09 23:04:43 +00:00
watson1978 d0015e4ac6 Improve performance of implicit type conversion
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
2017-05-31 12:30:57 +00:00
stomar a2b4979bbb hash.c: docs for Hash#transform_values
* hash.c: [DOC] fix return value in call-seq of Hash#transform_values;
  other small fixes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-25 15:14:38 +00:00
rhe 5565fed887 hash.c: [DOC] fix docs for Hash#transform_values!
Hash#transform_values! returns the receiver rather than a new Hash
object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-22 07:13:06 +00:00
kazu b4c2008817 Add missing word in transform_values methods description
Explicitly says that the methods return a new hash rather than just
stating it return a new something we don't know.

[ci skip]
[Fix GH-1619]
Author:    Nicolas Cavigneaux <nico@bounga.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-21 07:13:11 +00:00
watson1978 9cd66d7022 Improve Hash#merge performance
* hash.c (rb_hash_merge): use rb_hash_dup() instead of rb_obj_dup() to duplicate
    Hash object. rb_hash_dup() is faster duplicating function for Hash object
    which got rid of Hash#initialize_dup method calling.

    Hash#merge will be faster around 60%.
    [ruby-dev:50026] [Bug #13343] [Fix GH-1533]

### Before
                 user     system      total        real
Hash#merge   0.160000   0.020000   0.180000 (  0.182357)

### After
                 user     system      total        real
Hash#merge   0.110000   0.010000   0.120000 (  0.114404)

### Test code
require 'benchmark'

Benchmark.bmbm do |x|
  hash1 = {}
  100.times { |i| hash1[i.to_s] = i }
  hash2 = {}
  100.times { |i| hash2[(i*2).to_s] = i*2 }

  x.report "Hash#merge" do
    10000.times do
      hash1.merge(hash2)
    end
  end
end

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20 09:23:46 +00:00
usa f4b9134842 Encoding.default_internal should affect ENV on Windows like other platforms
* hash.c (env_str_transcode): call rb_external_str_with_enc() if
  default_internal is available.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-12 11:49:05 +00:00
shyouhei 29ca20de2d refactor newhash (revision 58463 another try) [fix GH-1600]
* st.c (rb_hash_bulk_insert): new API to bulk insert entries
	  into a hash. Given arguments are first inserted into the
	  table at once, then reindexed. This is faster than inserting
	  things using rb_hash_aset() one by one.

	  This arrangement (rb_ prefixed function placed in st.c) is
	  unavoidable because it both touches table internal and write
	  barrier at once.

	* internal.h: delcare the new function.

	* hash.c (rb_hash_s_create): use the new function.

	* vm.c (core_hash_merge): ditto.

	* insns.def (newhash): ditto.

	* test/ruby/test_hash.rb: more coverage on hash creation.

	* test/ruby/test_literal.rb: ditto.

-----------------------------------------------------------
benchmark results:
minimum results in each 7 measurements.
Execution time (sec)
name    before  after
loop_whileloop2  0.136  0.137
vm2_bighash*     1.249  0.623

Speedup ratio: compare with the result of `before' (greater is better)
name    after
loop_whileloop2 0.996
vm2_bighash*    2.004



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-27 04:21:04 +00:00
shyouhei a15fd1d9f2 revert newhash refactoring
We need to fix GC bug before merging this.  Revert revisions
58452, 58435, 58434, 58428, 58427 in this order.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-24 01:40:51 +00:00
ko1 a6f0ec21e9 mark Hash keys correctly.
* hash.c (rb_hash_new_from_object): same as r58434.
  Newly created frozen objects are not referred from any roots/objects.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-23 00:20:27 +00:00
nobu 0749e7be45 adjust indent
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-22 08:19:33 +00:00
ko1 5f5bc068ed insert WB correctly.
* hash.c (hash_insert_raw): should insert WB.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-21 15:00:30 +00:00
ko1 a7db632088 mark created frozen strings.
* hash.c (rb_hash_new_from_values_with_klass): before this fix,
  only a st table are filled with passed values. However, newly
  created frozen strings are not marked correctly only reference
  from st table. This patch marks such created frozen strings
  by Hash object which refers to the st table.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-21 11:02:10 +00:00
shyouhei 0c082fe658 typo fix (sorry!)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-21 04:42:09 +00:00
shyouhei 4ee09d914d refactor hash literal
Same as rb_ary_tmp_new_from_values(), it reduces vm_exec_core binary
size from 26,176 bytes to 26,080 bytes.  But this time, also with a
bit of optimizations:

  - Because we are allocating a new hash and no back references are
    introduced at all, we can safely skip write barriers.

  - Also, the iteration never recurs.  We can avoid complicated
    function callbacks by using st_insert instead of st_update.

----

	* hash.c (rb_hash_new_from_values): refactor
          extract the bulk insert into a function.

	* hash.c (rb_hash_new_from_object): also refactor.

	* hash.c (rb_hash_s_create): use the new functions.

	* insns.def (newhash): ditto.

	* vm.c (core_hash_from_ary): ditto.

	* iternal.h: export the new function.

-----------------------------------------------------------
benchmark results:
minimum results in each 7 measurements.
Execution time (sec)
name    before  after
loop_whileloop2  0.135  0.134
vm2_bighash*     1.236  0.687

Speedup ratio: compare with the result of `before' (greater is better)
name    after
loop_whileloop2 1.008
vm2_bighash*    1.798


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-21 04:21:14 +00:00
stomar 8b71e2532d hash.c: [DOC] fix book title in example
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-01 19:57:14 +00:00
stomar 6b82ba9e26 Fix doc for Hash#dig and Struct#dig
* hash.c (rb_hash_dig): [DOC] correct argument name
  in method description; fix formatting in examples.
* struct.c (rb_struct_dig): ditto.

[ruby-core:79221] [Bug #13148]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-27 18:07:11 +00:00
nobu 556a1352e4 backward.h: 2.2 deprecated features
* include/ruby/backward.h (DECLARE_DEPRECATED_FEATURE): move
  features deprecated at 2.2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-21 05:17:41 +00:00
kazu 9985b75940 Hash#fetch: fix grammar in documentation.
[Fix GH-1515][ci skip]
Author:    Alyssa Ross <hi+services.github@alyssa.is>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-22 03:06:17 +00:00
nobu c59e739b02 ENV#fetch: fix documentation of raised exception
[Fix GH-1514]
Author:    Misty De Meo <mistydemeo@github.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-19 06:39:44 +00:00
eregon ac9f8145f1 fix optimization for hash aset/aref with fstring
Patch by Eric Wong [ruby-core:78797].
I don't like the idea of making insns.def any bigger to support
a corner case, and "test_hash_aref_fstring_identity" shows
how contrived this is.

[ruby-core:78783] [Bug #12855]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-07 11:31:53 +00:00
nobu 9a464db8a8 hash.c: split long long literals
* hash.c (prime1, prime2): split long long literals for platforms
  where LL suffix is not supported, e.g., VC6.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-24 13:21:30 +00:00
naruse 5ec23b5222 Updated documentation examples for Hash#value?
The same code is used for has_value? and value?, but according to
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/43765
has_value is deprecated. Use the non-deprecated syntax in the examples.
by Herwin Weststrate <herwin@snt.utwente.nl>
fix https://github.com/ruby/ruby/pull/1491

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-10 18:34:07 +00:00
nobu f2b6e9f05f hash.c: hash should be long
* hash.c (any_hash): should return `long', because ruby assumes
  the hash value of the object id of an object is `long'.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-07 04:25:50 +00:00
nobu 5714a26b90 switching hash removal
* st.h (struct st_hash_type): Remove strong_hash.
  (struct st_table): Remove inside_rebuild_p and curr_hash.
* st.c (do_hash): Use type->hash instead of curr_hash.
  (make_tab_empty): Remove setting up curr_hash.
  (st_init_table_with_size): Remove setting up inside_rebuild_p.
  (rebuild_table): Remove clearing inside_rebuild_p.
  (reset_entry_hashes, HIT_THRESHOULD_FOR_STRONG_HASH): Remove code
  recognizing a denial attack and switching to strong hash.
* hash.c (rb_dbl_long_hash, rb_objid_hash, rb_ident_hash): Use
  rb_hash_start to randomize the hash.
  (str_seed): Remove.
  (any_hash): Remove strong_p and use always rb_str_hash for
  strings.
  (any_hash_weak, rb_any_hash_weak): Remove.
  (st_hash_type objhash): Remove rb_any_hash_weak.

based on the patch by Vladimir N Makarov <vmakarov@redhat.com> at
[ruby-core:78490].  [Bug #13002]

* test/ruby/test_hash.rb (test_wrapper): objects other than special
  constants should be able to be wrapped.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-06 04:43:48 +00:00
nobu 1e95f9da88 remove unnecessary variable
* st.c (do_hash): remove unnecessary variable and cast.

* hash.c, numeric.c, st.c: adjust style and indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-06 03:36:52 +00:00
kazu 9fa8006a01 Cleanup ruby method definitions in hash.c
Always add a space between a comma and the next element. These spaces
were there sometimes, but not always. This keeps to code consistent.

Patch by: Herwin Weststrate <herwin@snt.utwente.nl>

[ruby-core:78297] [Misc #12977] [GH-1492]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-03 11:18:44 +00:00
nobu ba8006533c add cast
* hash.c (rb_objid_hash): need to cast down.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-07 03:28:57 +00:00
ko1 75775157ea Introduce table improvement by Vladimir Makarov <vmakarov@redhat.com>.
[Feature #12142]
	See header of st.c for improvment details.

	You can see all of code history here:
	<https://github.com/vnmakarov/ruby/tree/hash_tables_with_open_addressing>

	This improvement is discussed at
	<https://bugs.ruby-lang.org/issues/12142>
	with many people, especially with Yura Sokolov.

	* st.c: improve st_table.

	* include/ruby/st.h: ditto.

	* internal.h, numeric.c, hash.c (rb_dbl_long_hash): extract a function.

	* ext/-test-/st/foreach/foreach.c: catch up this change.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-07 00:45:00 +00:00
nobu 4e44f6ef86 [DOC] replace Fixnum with Integer [ci skip]
* numeric.c: [DOC] update document for Integer class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26 06:11:23 +00:00
nobu 4154b96068 hash.c: fix Hash#compact! return value
* hash.c (rb_hash_compact_bang): should return nil if no elements
  is deleted.  [ruby-core:77709] [Bug #12863]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-22 09:52:35 +00:00
nobu bbd58fa2b9 hash.c: add compact and compact! methods
* hash.c (rb_hash_compact, rb_hash_compact_bang): Removes nil
  values from the original hash, to port Active Support behavior.
  [Feature #11818]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-13 08:06:00 +00:00
usa c2dd2d268e * internal.h (ST2FIX): new macro to convert st_index_t to Fixnum.
a hash value of Object might be Bignum, but it causes many troubles
  expecially the Object is used as a key of a hash.  so I've gave up
  to do so.

* array.c (rb_ary_hash): use above macro.

* bignum.c (rb_big_hash): ditto.

* hash.c (rb_obj_hash, rb_hash_hash): ditto.

* numeric.c (rb_dbl_hash): ditto.

* proc.c (proc_hash): ditto.

* re.c (rb_reg_hash, match_hash): ditto.

* string.c (rb_str_hash_m): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-04 16:25:01 +00:00
ngoto c1dbcf9b7e * hash.c (each_pair_i_fast): Fix compile error with old version of
fcc on Solaris 10. [Bug #12768] [ruby-dev:49808]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-16 12:20:35 +00:00
naruse d51aea54d8 * hash.c (each_pair_i_fast): use rb_yield_values2 to avoid var args.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-13 22:22:14 +00:00
akr 577de1e93d replace fixnum by integer in documents.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08 04:57:49 +00:00
mrkn eaa0a27f61 hash.c: map_v -> transform_values
* hash.c (rb_hash_transform_values, rb_hash_transform_values_bang):
  Rename map_v to transform_values.
  [Feature #12512] [ruby-core:76095]

* test/ruby/test_hash.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08 02:33:18 +00:00
nobu b22b725c5d util.h: POSIX-noncompliant setenv
* include/ruby/util.h (setenv): remove POSIX-noncompliant
  definition with 2 arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-07 08:50:39 +00:00
mrkn ea5184b939 hash.c: implement Hash#map_v and Hash#map_v!
* hash.c (rb_hash_map_v, rb_hash_map_v_bang): impelement Hash#map_v and
  Hash#map_v! [Feature #12512] [ruby-core:76095]

* test/ruby/test_hash.rb: add tests for above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-09 08:54:15 +00:00
nobu e70df3a701 hash.c: env_name_new
* hash.c (env_enc_str_new): make string for an environment
  variable name or value.
* hash.c (env_name_new): make environment value string with the
  encoding for its name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-05 15:39:46 +00:00
usa 549605c15d * hasn.c (env_str_new): taint the string. get rid of a test failure
introduced at r55811.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-05 14:19:26 +00:00
nobu cb0cde7f24 hash.c: call w32_getenv pointer
* hash.c (w32_getenv): call rb_w32_getenv and rb_w32_ugetenv via
  this pointer without further comparisons.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-05 08:04:04 +00:00
nobu 9e1b9b9c8f hash.c: set encoding
* hash.c (env_assoc): the encoding of the value should be the
  locale, as well as other methods, [], fetch, values, etc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-04 02:54:32 +00:00
nobu c463366dfd rb_funcallv
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions
  which are/will be/may be gems.  [Fix GH-1406]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-29 11:57:14 +00:00
nobu aa0e51b529 hash.c: rb_hash_add_new_element
* hash.c (rb_hash_add_new_element): add new element or do nothing
  if it is contained already.
* array.c (ary_add_hash, ary_add_hash_by): use
  rb_hash_add_new_element.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-20 08:35:25 +00:00
nobu 2667d1b38f hash.c: ensure NUL-terminated for ENV
* hash.c (get_env_cstr): ensure NUL-terminated.
  [ruby-dev:49655] [Bug #12475]
* string.c (rb_str_fill_terminator): return the pointer to the
  NUL-terminated content.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-10 05:48:38 +00:00
usa 62b6e90d58 * cont.c, hash.c, random.c, win32/win32.c: cleanup some Win9x/ME/NT4
support leftovers.
  [fix GH-1328] patched by @cremno


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-01 11:42:41 +00:00
nobu a19b53aeab hash.c: dry up code
* hash.c (rb_hash_update_{block,func}_callback): dry up hash
  update callback code.  [Fix GH-1338]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-28 08:03:19 +00:00
nobu 2f6821a7c4 hash.c: init table with size
* hash.c (rb_hash_s_create): allocate internal table with the
  given size.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-30 08:21:18 +00:00
mrkn f8e79c84a9 * bignum.c (rb_big_hash): make it public function to be available in
other source files, and remove documentation comment for Bignum#hash.

* bignum.c (Bignum#hash): remove its definition because it is unified
  with Object#hash.

* include/ruby/intern.h (rb_big_hash): add a prototype declaration.

* hash.c (any_hash): treat Bignum values directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-18 01:22:38 +00:00
nobu 2d3a6ba66d hash.c: COPY_DEFAULT
* hash.c (COPY_DEFAULT): new macro to copy the default value/proc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-09 07:17:04 +00:00
nobu e684069042 hash.c: SET_PROC_DEFAULT
* hash.c (SET_PROC_DEFAULT): new macro to set the default proc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-09 07:17:03 +00:00
nobu 7522e06424 hash.c: SET_DEFAULT
* hash.c (SET_DEFAULT): new macro to set the default value.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-09 07:17:03 +00:00
nobu 921d6e269d hash.c: hash_dup for rb_hash_to_h
* hash.c (rb_hash_to_h): share hash_dup to copy the contents and
  the default value/proc only.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-09 07:17:02 +00:00
nobu 865a326da9 hash.c: make duplicated hash WB protected
* hash.c (hash_alloc_flags): allocate new hash with the flags and
  the default value.

* hash.c (hash_dup): duplicate with the flags and the default
  value.

* hash.c (rb_hash_dup): make the duplicated hash write-barrier
  protected.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-09 07:17:01 +00:00
nobu d000891e43 hash.c: tbl_update_func
* hash.c (tbl_update_func): extract function typedef from the
  declaration of tbl_update.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-09 04:45:27 +00:00
akr f061d40326 * hash.c (rb_hash_invert): [DOC] more examples.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-13 12:45:59 +00:00
nobu b14ea7d05b hash.c: exception examples
* hash.c (rb_hash_dig): [DOC] add examples of exceptions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-27 07:30:42 +00:00
nobu 39cf3780e5 hash.c: trivial optimization
* hash.c (rb_hash_initialize_copy): trivial optimization, copy
  HASH_PROC_DEFAULT bit directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-14 02:15:00 +00:00
ngoto cef1f23e89 * gc.c: Delete excess semicolon after RUBY_ALIAS_FUNCTION().
Suppress "syntax error:  empty declaration" warnings by
  Oracle Solaris Studio 12.x on Solaris. [Bug #11821]

* hash.c: ditto, after NOINSERT_UPDATE_CALLBACK().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-15 14:20:27 +00:00
normal e52b3a0e2c hash.c (rb_num_hash_start): avoid pathological behavior
The OR-ing itself is bad for a hash function, and shifting 3 bits
left was not enough to undo the damage done by shifting
(RUBY_SPECIAL_SHIFT+3) bits right.  Experimentally, shifting 16-17
bits seemed to work well in preparing the number for murmur hash.

Add a few more benchmarks to based on bm_hash_shift to ensure
we don't hurt performance too much with tweaks.

I'm pretty confident about this change and commiting it now;
especially since we're still using Murmur behind it (but perhaps
we can update to a newer hash from Murmur...)

[ruby-core:72028] [Feature #11405]

target 0: a (ruby 2.3.0dev (2015-12-11 trunk 53027) [x86_64-linux]) at "/home/ew/rrrr/b/ruby"
target 1: b (ruby 2.3.0dev (2015-12-11 master 53027) [x86_64-linux]) at "/home/ew/ruby/b/ruby"

benchmark results:
minimum results in each 5 measurements.
Execution time (sec)
name	a	b
hash_aref_dsym	0.279	0.276
hash_aref_dsym_long	4.951	4.936
hash_aref_fix	0.281	0.283
hash_aref_flo	0.060	0.060
hash_aref_miss	0.409	0.410
hash_aref_str	0.387	0.385
hash_aref_sym	0.275	0.270
hash_aref_sym_long	0.410	0.411
hash_flatten	0.252	0.237
hash_ident_flo	0.035	0.032
hash_ident_num	0.254	0.251
hash_ident_obj	0.252	0.256
hash_ident_str	0.250	0.252
hash_ident_sym	0.259	0.270
hash_keys	0.267	0.267
hash_shift	0.016	0.015
hash_shift_u16	0.074	0.072
hash_shift_u24	0.071	0.071
hash_shift_u32	0.073	0.072
hash_to_proc	0.008	0.008
hash_values	0.263	0.264

Speedup ratio: compare with the result of `a' (greater is better)
name	b
hash_aref_dsym	1.009
hash_aref_dsym_long	1.003
hash_aref_fix	0.993
hash_aref_flo	1.001
hash_aref_miss	0.996
hash_aref_str	1.006
hash_aref_sym	1.017
hash_aref_sym_long	0.998
hash_flatten	1.061
hash_ident_flo	1.072
hash_ident_num	1.012
hash_ident_obj	0.987
hash_ident_str	0.993
hash_ident_sym	0.959
hash_keys	0.997
hash_shift	1.036
hash_shift_u16	1.039
hash_shift_u24	1.001
hash_shift_u32	1.017
hash_to_proc	1.001
hash_values	0.995

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-11 08:23:46 +00:00
nobu 165e10b6cf compile.c: rehash cdhash
* compile.c (iseq_compile_each, ibf_load_object_hash): rehash
  case-dispatch hash to reduce collisions.
  http://d.hatena.ne.jp/ku-ma-me/20151210

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-11 02:38:20 +00:00
marcandre cb3b463a50 * array.c: Improve and fix documentation for Array#dig
[#11776]

* hash.c: ditto

* struct.c: ditto

* test_hash.rb: Add basic test for user defined `dig`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 05:21:11 +00:00
nobu f534bc2ed9 hash.c: fix rubyspec failure
* hash.c (env_fetch): yield coerced string.

* hash.c (env_assoc): return coerced string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-06 12:13:25 +00:00
nobu 5e3467c441 hash.c: env encoding fallback on Windows
* hash.c (env_str_new, env_path_str_new): make default string
  UTF-8 for the case conversion is not possible.  [Bug #8822]
* hash.c (get_env_cstr): convert non-ASCII string to UTF-8 string.
* hash.c (ruby_setenv): use wide char version to put environment
  variable to deal with non-ASCII value.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-05 08:26:26 +00:00
nobu 0701e5ff46 update rdoc of dig methods [ci skip]
* array.c (rb_ary_dig), hash.c (rb_hash_dig): [DOC] Update
  comments describing dig methods.  [Fix GH-1103]
* struct.c (rb_struct_dig): [DOC] add rdoc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17 02:25:28 +00:00
nobu 59a3fe5846 hash.c: compare methods [ci skip]
* hash.c (rb_hash_{le,lt,ge,gt}): [DOC] for [Feature #10984]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-14 08:13:11 +00:00
nobu 56e3b49304 sprintf.c: nil value is valid
* sprintf.c (rb_str_format): look up the key, then get default
  value and raise KeyError if the returned value is nil.
  [ruby-dev:49338] [Ruby trunk - Bug #11677]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-11 09:30:31 +00:00
nobu 16e7869ded hash.c: use rb_func_proc_new
* hash.c (rb_hash_to_proc): use rb_func_proc_new to make light
  weight proc.  [Feature #11653]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-10 09:25:58 +00:00
nobu fbe967ec02 hash.c: to_proc
* hash.c (rb_hash_to_proc): new method Hash#to_proc.
  [Feature #11653]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-10 07:57:17 +00:00
nobu d68c3ecf98 hash.c: compare methods
* hash.c (rb_hash_{le,lt,ge,gt}): new methods, Hash#<=, Hash#<,
  Hash#>=, Hash#>, to test if all elements of a hash are also
  included in another hash, and vice versa.
  [ruby-core:68561] [Feature #10984]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-10 05:02:02 +00:00
nobu 29862685c0 dig
* array.c (rb_ary_dig): new method Array#dig.
* hash.c (rb_hash_dig): new method Hash#dig.
* object.c (rb_obj_dig): dig in nested arrays/hashes.
  [Feature #11643]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-09 12:27:26 +00:00
nobu 12c244d347 hash.c: fix oob access
* hash.c (rb_hash_default): do not access argv when no arguments
  is given.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-08 08:32:51 +00:00
hsbt b6807ba353 * hash.c: use correct grammer. Patch by @tveastman
[fix GH-1079][ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-04 06:39:37 +00:00
nobu 645116ff25 RUBY_DTRACE_CREATE_HOOK
* 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-29 05:32:57 +00:00
nobu c416efa440 hash.c: GC guards
* hash.c (env_delete, env_aset): prevent environment variable
  names from GC while ruby_setenv.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-25 07:08:45 +00:00
nobu 5381e4d1c0 hash.c: [DOC] orders do not matter [ci skip]
* hash.c (rb_hash_equal, rb_hash_eql): [DOC] the orders of each
  hashes are not compared.  [Bug #11508]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-04 23:29:01 +00:00
normal 14470aa6db hash.c: improve integer/fixnum hashing
The low bits of Ruby object IDs are rarely populated in the current
implementation, so ensure the get used.

Early versions of this patch redundantly shifted static symbols in
any_hash, causing regresions with static symbols in hash_aref_sym

* hash.c (any_hash): skip rb_objid_hash for static syms
  (rb_num_hash_start): extract from rb_ident_hash
  (rb_objid_hash): call rb_num_hash_start
  (rb_ident_hash): ditto
  [ruby-core:70181] [Feature #11405]

target 0: a (ruby 2.3.0dev (2015-07-30 trunk 51437) [x86_64-linux]
target 1: b (ruby 2.3.0dev (2015-07-30 patch 51437) [x86_64-linux]

benchmark results from Xeon E3-1230 v3 @ 3.30GHz (turbo disabled):
minimum results in each 10 measurements.
Execution time (sec)
name                a       b
hash_aref_dsym        0.316   0.300
hash_aref_dsym_long   5.106   5.063
hash_aref_fix         0.304   0.297
hash_aref_flo         0.061   0.060
hash_aref_miss        0.433   0.430
hash_aref_str         0.408   0.396
hash_aref_sym         0.312   0.306
hash_aref_sym_long    0.482   0.469
hash_flatten          0.385   0.273
hash_ident_flo        0.036   0.037
hash_ident_num        0.277   0.276
hash_ident_obj        0.291   0.284
hash_ident_str        0.289   0.286
hash_ident_sym        0.285   0.281
hash_keys             0.269   0.271
hash_shift            0.020   0.016
hash_values           0.264   0.264
loop_whileloop2       0.101   0.099
vm2_bighash*          3.066   2.972

Speedup ratio: compare with the result of `a' (greater is better)
name                b
hash_aref_dsym        1.052
hash_aref_dsym_long   1.008
hash_aref_fix         1.024
hash_aref_flo         1.015
hash_aref_miss        1.007
hash_aref_str         1.031
hash_aref_sym         1.018
hash_aref_sym_long    1.027
hash_flatten          1.410
hash_ident_flo        0.994
hash_ident_num        1.001
hash_ident_obj        1.022
hash_ident_str        1.012
hash_ident_sym        1.016
hash_keys             0.992
hash_shift            1.237
hash_values           1.001
loop_whileloop2       1.013
vm2_bighash*          1.032

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-14 19:52:06 +00:00
zzak cdb58a19cc * hash.c: [DOC] Improve description of symbol key syntax
Patch by Raphael Das Gupta in documenting-ruby/ruby#51:
  https://github.com/documenting-ruby/ruby/pull/51


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-07 18:42:01 +00:00
nobu ede1c141c6 symbol.c: fix dynamic symbol hash value
* hash.c (any_hash), symbol.c (dsymbol_alloc): fix dynamic symbol
  hash value by restricting in Fixnum range, that is `long`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-29 12:38:43 +00:00
nobu 987df2ece6 hash.c: move rb_obj_hash
* 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-29 08:25:49 +00:00
nobu 48f9012df9 hash.c: fix symbol hash
* 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-29 05:54:21 +00:00
nobu efc7a3a712 hash.c: fix float hash
* hash.c (rb_any_hash): fix Float hash.  rb_dbl_hash() returns a
  Fixnum, but not a long.  [Bug #9381]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-29 05:53:35 +00:00
normal 442b77e721 symbol.h: memoize hashval for RSymbol
This speeds up the hash function for dynamic symbols.
[ruby-core:70129] [Bug #11396], nearly up to Ruby 2.1 levels

Power-of-two hash sizing [Feature #9425] speeds up cases where we
have a good hash, but this means we can no longer hide behind weak
hashes.  Unfortunately, object IDs do not hash well, but we may
use the extra space in the RSymbol struct to memoize the hash value.

Further optimizations should be possible.  For now, the st.c APIs
force us to calculate rb_str_hash redundantly at dsym registration.

* symbol.h (struct RSymbol): add hashval field
* symbol.c (dsymbol_alloc): setup hashval field once
* hash.c (rb_any_hash): return RSymbol->hashval directly
* common.mk: hash.o depends on symbol.h
  Thanks to Bruno Escherl <bruno@escherl.net> for the bug report
  [ruby-core:70129] [Bug #11396]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-27 22:25:30 +00:00
normal 9f1c009497 enum.c (enum_minmax): simplify return value creation
No need to call three functions on success when one will do.
This results in less LoC and smaller object code, too:

   text    data     bss     dec     hex filename
  33860       0     296   34156    856c gcc/enum.o-before
  33852       0     296   34148    8564 gcc/enum.o

* enum.c (enum_minmax): simplify return value creation
* test/ruby/test_enum.rb: test behavior on empty

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-25 23:06:48 +00:00
nobu 86eaa24570 hash.c: fetch_values
* hash.c (rb_hash_fetch_values): add `Hash#fetch_values`.
  [Feature #10017] [Fix GH-776]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-12 08:34:17 +00:00
ko1 258131446c * class.c (rb_class_has_methods): added to reduce depenedency
to internal class data structure.
* internal.h: ditto.
* hash.c (has_extra_methods): use added function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-31 19:17:18 +00:00
nobu adfeb95c87 hash.c: check env vars encoding
* hash.c (get_env_cstr): environment variables must be ASCII
  compatible, as dummy encodings and wide char encodings are
  unsupproted now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-19 01:42:57 +00:00
nobu 622193d32a hash.c: compare symbols by identities
* hash.c (rb_any_hash): Symbols are compared by the identities
  always.  [ruby-core:68767] [Bug #11035]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-08 04:01:06 +00:00
nobu 3bcf9fb53e hash.c: same hash values with Float#hash
* hash.c (rb_any_hash): use same hash values with Float#hash so
  that -0.0 and +0.0 will be identical.
  [ruby-core:68541] [Bug #10979]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18 03:01:58 +00:00
gogotanaka 744a858bd2 * hash.c: [DOC] #delete method actually returns nil, if the key
is not found. [fix GH-844][ci skip] Patch by @ivdma

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-05 08:00:14 +00:00
nobu 802d71a57e [DOC] ENV keys must be strings [ci skip]
* hash.c (env_aset): state that ENV keys must be strings.

* process.c (rb_f_spawn): ditto.  [ruby-core:68146] [Bug #10859]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-18 02:42:58 +00:00
hsbt f6b9a0feaf * hash.c: Added docs to explain that #include? and #member? do not
check member equality
* lib/set.rb: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-17 01:47:28 +00:00
nobu e567f351c2 marshal.c: indetity tables
* marshal.c (w_object, marshal_dump): use indetity tables for
  arbitrary VALUE keys, because of performance of FLONUM.
  [Bug #10761]
* marshal.c (obj_alloc_by_klass, marshal_load): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-23 11:01:02 +00:00
nobu 059ea6e4d8 hash.c: move Hash specific functions
* hash.c (rb_ident_hash): move compare_by_identity specific
  function from st.c.

* hash.c (rb_ident_hash_new): ditto from thread.c.

* st.c (st_numhash): remove ruby's Hash specific implementation.

* thread.c (recursive_list_access): use rb_ident_hash_new().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-23 02:36:50 +00:00
normal 6d56fd067e fix flonum hashing regression from r45384
* st.c (st_numhash): mix float value for flonum
* hash.c (rb_any_hash): ditto
* benchmark/bm_hash_aref_flo.rb: new benchmark
* benchmark/bm_hash_ident_flo.rb: ditto
  [Bug #10761]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-22 07:48:59 +00:00
ayumin 45ecc02716 * hash.c: fix docs for Hash#invert. [ruby-core:66917] [Bug #10612]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03 15:00:31 +00:00
ko1 9c6eaad723 * hash.c (rb_hash_delete): return Qnil if there are no corresponding
entry. [Bug #10623]
* hash.c (rb_hash_delete_entry): try delete and return Qundef if there
  are no corresponding entry.
* internal.h: add rb_hash_delete_entry()'s declaration.
* symbol.c: use rb_hash_delete_entry().
* thread.c: use rb_hash_delete_entry().
* ext/-test-/hash/delete.c: use rb_hash_delete_entry().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-24 02:53:37 +00:00
nobu 62d43632ba hash.c: fix return value
* hash.c (hash_equal): prefer true than the result of implicit
  conversion from int returned by rb_eql() to VALUE.  [Fix GH-789]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-19 06:36:05 +00:00
akr 2b9191e557 * internal.h: Gather declarations in non-header files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 15:13:05 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
ko1 5d5c95f28e * gc.c (gc_stat_internal): add compatible layer.
From Ruby 2.2, keys of GC.stat are changed [Feature #9924].
  To provide compatible layer, GC.stat add a default_proc
  (if default_proc of given Hash object is not set).
  At first use of this compatible layer of interpreter process,
  show a warning message like that:
  program: GC.stat[:total_allocated_object]
  warning message: "warning: GC.stat keys were changed from Ruby
  2.1. In this case,  you refer to obsolete `total_allocated_object'
  (new key is `total_allocated_objects').
  Please check <https://bugs.ruby-lang.org/issues/9924>
  for more information."
  Pleaes correct my English message :)
* hash.c (rb_hash_set_default_proc): export (in internal).
* internal.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-14 07:29:33 +00:00
ko1 fbebd502f9 * rewrite method/block parameter fitting logic to optimize
keyword arguments/parameters and a splat argument.
  [Feature #10440] (Details are described in this ticket)
  Most of complex part is moved to vm_args.c.
  Now, ISeq#to_a does not catch up new instruction format.
* vm_core.h: change iseq data structures.
  * introduce rb_call_info_kw_arg_t to represent keyword arguments.
  * add rb_call_info_t::kw_arg.
  * rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num.
  * rename rb_iseq_t::arg_keywords to arg_keyword_num.
  * rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits.
    to represent keyword bitmap parameter index.
    This bitmap parameter shows that which keyword parameters are given
    or not given (0 for given).
    It is refered by `checkkeyword' instruction described bellow.
  * rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest
    to represent keyword rest parameter index.
  * add rb_iseq_t::arg_keyword_default_values to represent default
    keyword values.
  * rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE
    to represent
      (ci->flag & (SPLAT|BLOCKARG)) &&
      ci->blockiseq == NULL &&
      ci->kw_arg == NULL.
* vm_insnhelper.c, vm_args.c: rewrite with refactoring.
  * rewrite splat argument code.
  * rewrite keyword arguments/parameters code.
  * merge method and block parameter fitting code into one code base.
* vm.c, vm_eval.c: catch up these changes.
* compile.c (new_callinfo): callinfo requires kw_arg parameter.
* compile.c (compile_array_): check the last argument Hash object or
  not. If Hash object and all keys are Symbol literals, they are
  compiled to keyword arguments.
* insns.def (checkkeyword): add new instruction.
  This instruction check the availability of corresponding keyword.
  For example, a method "def foo k1: 'v1'; end" is cimpiled to the
  following instructions.
    0000 checkkeyword     2, 0  # check k1 is given.
    0003 branchif         9     # if given, jump to address #9
    0005 putstring        "v1"
    0007 setlocal_OP__WC__0 3   # k1 = 'v1'
    0009 trace            8
    0011 putnil
    0012 trace            16
    0014 leave
* insns.def (opt_send_simple): removed and add new instruction
  "opt_send_without_block".
* parse.y (new_args_tail_gen): reorder variables.
  Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)"
  has parameter variables "k1, kr1, k2, &b, internal_id, krest",
  but this patch reorders to "kr1, k1, k2, internal_id, krest, &b".
  (locate a block variable at last)
* parse.y (vtable_pop): added.
  This function remove latest `n' variables from vtable.
* iseq.c: catch up iseq data changes.
* proc.c: ditto.
* class.c (keyword_error): export as rb_keyword_error().
* common.mk: depend vm_args.c for vm.o.
* hash.c (rb_hash_has_key): export.
* internal.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02 18:02:55 +00:00
nobu ca7835bec6 hash.c: rb_hash_delete does not call the block
* hash.c (rb_hash_delete): now does not call the block given to
  the current method.  [ruby-core:65861] [Bug #10413]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-23 12:42:57 +00:00
normal 3cb3966838 hash.c (rb_any_hash): remove unnecessary dsym check
gcc (Debian 4.7.2-5) 4.7.2 on x86 generates smaller code this
way, as it does not seem to be able to reuse the result of
SPECIAL_CONST_P.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-09 03:39:02 +00:00
nobu 28b9f11d5a protoize no-arguments functions
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-30 05:25:32 +00:00
nobu f3c9ffe094 hash.c: [DOC] fix for Hash#store docs
* hash.c (rb_hash_aset): fix misleading example which may suggest
  that Hash.store will return self instead of value - Hash#store
  is returning value and update itself, as well as Hash#[]=.
  [Fix GH-715]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-13 13:19:27 +00:00
ko1 123eeb1c1a * gc.c: add incremental GC algorithm. [Feature #10137]
Please refer this ticket for details.
  This change also introduces the following changes.
  * Remove RGENGC_AGE2_PROMOTION and introduce object age (0 to 3).
    Age can be count with FL_PROMOTE0 and FL_PROMOTE1 flags in
    RBasic::flags (2 bit). Age == 3 objects become old objects.
  * WB_PROTECTED flag in RBasic to WB_UNPROTECTED bitmap.
  * LONG_LIVED bitmap to represent living objects while minor GCs
    It specifies (1) Old objects and (2) remembered shady objects.
  * Introduce rb_objspace_t::marked_objects which counts marked
    objects in current marking phase. marking count is needed to
    introduce incremental marking.
  * rename mark related function and sweep related function to
    gc_(marks|sweep)_(start|finish|step|rest|continue).
  * rename rgengc_report() to gc_report().
  * Add obj_info() function to get cstr of object details.
  * Add MEASURE_LINE() macro to measure execution time of specific line.
  * and many small fixes.
* include/ruby/ruby.h: add flag USE_RINCGC.
  Now USE_RINCGC can be set only with USE_RGENGC.
* include/ruby/ruby.h: introduce FL_PROMOTED0 and add FL_PROMOTED1
  to count object age.
* include/ruby/ruby.h: rewrite write barriers for incremental marking.
* debug.c: catch up flag name changes.
* internal.h: add rb_gc_writebarrier_remember() instead of
  rb_gc_writebarrier_remember_promoted().
* array.c (ary_memcpy0): use rb_gc_writebarrier_remember().
* array.c (rb_ary_modify): ditto.
* hash.c (rb_hash_keys): ditto.
* hash.c (rb_hash_values): ditto.
* object.c (init_copy): use rb_copy_wb_protected_attribute() because
  FL_WB_PROTECTED is moved from RBasic::flags.
* test/objspace/test_objspace.rb: catch up ObjectSpace.dump() changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-08 04:11:00 +00:00
nobu d738e3e155 optimized any? methods
* array.c (rb_ary_any_p), hash.c (rb_hash_any_p): optimized
  versions.  these are bit faster than optimization in
  Enumerable#any?.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-18 13:16:48 +00:00
ngoto 90b1b2e607 * hash.c (ruby_setenv): Fix TestEnv#test_aset failure on Solaris 9.
When name contains '=', ruby_setenv raises Errno::EINVAL.
  That is the same behavior as Solaris 10.
  NULL check for malloc return value is also added.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-10 15:22:07 +00:00
nobu 255adda52f hash.c: use rb_check_arity
* hash.c (rb_hash_initialize, rb_hash_fetch_m, rb_hash_default):
  use rb_check_arity over rb_scan_args.
  (env_fetch): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-02 08:25:21 +00:00
nobu 68bc5ba1b6 hash.c: fix memory leak
* hash.c (env_shift): fix memory leak on Windows, free environment
  strings block always.  [ruby-dev:48332] [Bug #9983]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-26 20:33:34 +00:00
nobu 78c763a25c hash.c: fix memory leak
* hash.c (env_select): fix memory leak and crash on Windows, make
  keys array first instead of iterating on envrion directly.
  [ruby-dev:48325] [Bug #9978]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-25 23:28:04 +00:00
nobu 7eeaf208b4 hash.c: fix dangling pointer
* hash.c (env_name): also store a coerced string to get rid of a
  dangling pointer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-25 22:43:23 +00:00
nobu 4198f1473a hash.c: fix memory leak
* hash.c (ruby_setenv): fix memory leak on Windows, free
  environment strings block after check for the size.
  [ruby-dev:48323] [Bug #9977]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-25 13:31:34 +00:00
nobu e1884ec820 hash.c: env_name
* hash.c (get_env_ptr, env_name): extract check for bad
  environment variable name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-25 12:18:53 +00:00
nobu 51a1c68bc7 hash.c: prohibit tainted strings
* hash.c (env_aset, env_has_key, env_assoc, env_has_value),
  (env_rassoc, env_key): prohibit tainted strings if $SAFE is
  non-zero.  [Bug #9976]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-25 01:20:01 +00:00
nobu 20014eb3e0 hash.c: unused functions on non-Windows
* hash.c (invalid_envname, check_envname): not used on platforms
  other than Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-24 18:24:24 +00:00
nobu c5255bdd03 hash.c: env_str_transcode
* hash.c (env_str_transcode): convert with replacing invalid/undef
  characters, on Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-24 18:02:31 +00:00
nobu 9a6518abf7 hash.c: replace undef
* hash.c (env_str_new, env_path_str_new): replace invalid or
  undefined conversions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-24 02:19:09 +00:00
nobu 5c9bc9f8e1 hash.c: frozen PATH env
* hash.c (env_path_str_new): make PATH environment variable
  string, to be frozen.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-24 01:50:09 +00:00
shyouhei 8250aa2df0 * include/ruby/ruby.h (struct RHash): no longer. [Feature #9889]
* include/ruby/ruby.h (RHASH): ditto.

	* include/ruby/ruby.h (RHASH_ITER_LEV): deprecated.  Will be deleted later.

	* include/ruby/ruby.h (RHASH_IFNONE): ditto.

	* internal.h (struct RHash): moved here.

	* internal.h (RHASH): ditto.

	* hash.c (rb_hash_iter_lev): do not use this.

	* hash.c (rb_hash_ifnone): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23 07:26:03 +00:00
nobu 7f3b12f05b use predefined IDs
* array.c (rb_ary_equal), hash.c (hash_equal): use predefined IDs,
  `to_ary` and `to_hash` respectively.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-20 08:28:31 +00:00
nobu 5bec2d8ccd hash.c: make rb_hash_keys extern
* hash.c (rb_hash_keys): make an internal public function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 04:26:53 +00:00
nobu 10cf7c5b2a hash.c: use ID_SCOPE_SHIFT
* hash.c (rb_any_hash): use ID_SCOPE_SHIFT instead of magic number.
  [Feature #9425]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-23 01:10:12 +00:00
normal ef59670a44 st.c: use power-of-two sizes to avoid slow modulo ops
* st.c (hash_pos): use bitwise AND to avoid slow modulo op
  (new_size): power-of-two sizes for hash_pos change
  (st_numhash): adjust for common keys due to lack of prime modulo
  [Feature #9425]
* hash.c (rb_any_hash): right shift for symbols
* benchmark/bm_hash_aref_miss.rb: added to show improvement
* benchmark/bm_hash_aref_sym_long.rb: ditto
* benchmark/bm_hash_aref_str.rb: ditto
* benchmark/bm_hash_aref_sym.rb: ditto
* benchmark/bm_hash_ident_num.rb: added to prevent regression
* benchmark/bm_hash_ident_obj.rb: ditto
* benchmark/bm_hash_ident_str.rb: ditto
* benchmark/bm_hash_ident_sym.rb: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-22 23:34:21 +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 1f29e8e2ba class.c: do nothing if copying self
* class.c (rb_mod_init_copy): do nothing if copying self.
  [ruby-dev:47989] [Bug #9535]
* hash.c (rb_hash_initialize_copy): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-21 11:42:03 +00:00
glass 13834fb3cb * hash.c (rb_hash_flatten): fix behavior of flatten(0).
[ruby-dev:47988] [Bug #9533]

* test/ruby/test_array.rb: test for above. patch is from
  Takeshi Sasaki.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-20 03:09:13 +00:00
glass f138018e9e * hash.c (rb_hash_flatten): fix behavior of flatten(-1).
[ruby-dev:47988] [Bug #9533]

* test/ruby/test_array.rb: test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-20 02:27:30 +00:00
tmm1 58f800a278 insns.def: add opt path for Hash#[] and Hash#[]= used with str literal keys
* insns.def (opt_aref_with): new instruction to optimize Hash#[],
  removing any allocation overhead when used with a string literal
  key. Patch by normalperson (Eric Wong). [ruby-core:59640] [Bug #9382]
* insns.def (opt_aset_with): new instruction to optimize Hash#[]=
* compile.c (iseq_compile_each): compiler shortcuts for new
  instructions
* hash.c (static VALUE rb_hash_compare_by_id_p): fix documentation for
  Hash#compare_by_identity to reflect frozen string sharing
* test/ruby/test_hash.rb (class TestHash): test for new behavior

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-10 04:54:08 +00:00
usa ac2864a871 * hash.c (rb_objid_hash): should return `long'. brushup r44534.
* object.c (rb_obj_hash): follow above change.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-09 11:34:17 +00:00
usa 8abc55bc54 * hash.c (rb_any_hash): should treat the return value of rb_objid_hash()
as `long', because ruby assumes the object id of an object is `long'.
  this fixes test failures on mswin64 introduced at r44525.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-09 08:42:42 +00:00
nobu ab6efa5be2 object.c: hash value from objid with salt
* hash.c (rb_objid_hash): return hash value from object ID with a
  salt, extract from rb_any_hash().
* object.c (rb_obj_hash): return same value as rb_any_hash().
  fix r44125.  [ruby-core:59638] [Bug #9381]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-08 06:55:24 +00:00
glass 2c11bda8b9 * hash.c (rb_hash_keys): make rb_hash_keys() static.
it is no longer used from array.c since r43969.
  the patch is from normalperson (Eric Wong).
  [ruby-core:59449] [Feature #9336]

* internal.h: remove definition of rb_hash_keys().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-01 15:19:23 +00:00
nobu 4ce4f43f91 hash.c: remove dead code
* hash.c (rb_hash_reject): remove dead code for the deprecated
  behavior.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-26 05:28:24 +00:00
nobu 3a247f6489 hash.c: no extra states copy
* hash.c (HASH_REJECT_COPY_EXTRA_STATES): turn off the old
  behavior, copying extra states by accident.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-26 05:25:08 +00:00
nobu af17af1faa hash.c: extra states
* hash.c (rb_hash_reject): use words "extra states".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-24 01:13:40 +00:00
nobu bc159ec502 hash.c: fix infinite loop
* hash.c (has_extra_methods): traverse ancestors, and fix infinite
  loop.  [Bug #9275]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-23 09:01:05 +00:00
nobu cb62186b07 hash.c: fix commit miss
* hash.c (HAS_EXTRA_STATES): remove extra parenthesis.
  [Bug #9275]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-23 07:00:01 +00:00
nobu c25c84777c hash.c: reduce warning
* hash.c (HAS_EXTRA_STATES): warn extra states only when something
  differ.  [ruby-core:59254] [Bug #9275]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-23 06:53:51 +00:00
nobu 21e74f5481 hash.c: reword
* hash.c (HAS_EXTRA_STATES, rb_hash_reject): use words
  "extra states".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-23 06:53:17 +00:00
ko1 c702005a7b * include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
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-20 08:07:47 +00:00
nobu 571955c13f hash.c: revert
* hash.c (rb_hash_reject): revert to deprecated behavior, with
  warnings, due to compatibility for HashWithDifferentAccess.
  [ruby-core:59154] [Bug #9223]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-17 11:15:00 +00:00
nobu cf460c34f7 hash.c: add warnings
* hash.c (rb_hash_reject): warn attributes in detail more.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-17 11:01:37 +00:00
nobu 26e425e6f4 hash.c: typo
* hash.c (rb_hash_reject): fix typo in macro name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-16 14:36:14 +00:00
nobu 0988148782 hash.c: warnings in rb_hash_reject
* hash.c (rb_hash_dup_empty): split from rb_hash_dup.

* hash.c (rb_hash_reject): add warnings (currently suppressed).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-16 13:40:04 +00:00
nobu 6cd0d06bae hash.c: refactor loop
* hash.c (rb_hash): rewrite with while instead of goto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-16 13:40:02 +00:00
nobu 740535f843 hash.c: reject should return a plain hash
* hash.c (rb_hash_reject): return a plain hash, without copying
  the class, default value, instance variables, and taintedness.
  they had been copied just by accident.
  [ruby-core:59045] [Bug #9223]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-11 07:01:29 +00:00
nobu 037a9d0655 array.c, hash.c: add salt
* array.c (rb_ary_hash): add salt to differentiate false and empty
  array.  [ruby-core:58993] [Bug #9231]
* hash.c (rb_any_hash, rb_hash_hash): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 14:44:51 +00:00
tmm1 a111923062 hash.c: fix segv in Hash#replace
* hash.c (rb_hash_replace): fix segv on `{}.replace({})` introduced
  in r44060 [Bug #9230] [ruby-core:58991]
* test/ruby/test_hash.rb: regression test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-09 10:06:49 +00:00
nobu cf85aaf83e hash.c: reject shoult infect
* hash.c (rb_hash_reject): result should be infected by the
  receiver.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 11:25:06 +00:00
tmm1 3dd248f13d hash.c: fix WB miss issue in Hash#replace
* hash.c (rb_hash_replace): add a write barrier to fix GC mark miss on
  hashes using Hash#replace [Bug #9226] [ruby-core:58948]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 03:03:42 +00:00
tmm1 779ae78995 hash.c: revert r43870 and add alternative parser patch for literal keys
* hash.c (hash_aset_str): revert r43870 due to performance issue
  [Bug #9188] [ruby-core:58730]
* parse.y (assoc): convert literal string hash keys to fstrings
* test/ruby/test_hash.rb (class TestHash): expand test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 01:52:28 +00:00
nobu 7416073cde hash.c: rb_hash_reject without dup
* hash.c (rb_hash_reject): copy unrejected elements only to new hash,
  so that the change on the original receiver can affect.
  [ruby-core:58914] [Bug #9223]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-07 02:16:04 +00:00
nobu 1bbc52dee1 hash.c: bail out to the outermost frame
* hash.c (rb_hash): revert r43981 and bail out to the outermost frame
  when recursion is detected.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 05:40:43 +00:00
nobu 218d1f5e1e hash.c: same hash value for similar constructs
* hash.c (rb_hash_recursive): make similar (recursive) constructs
  return same hash value.  execute recursively, and rewind to the
  topmost frame with an object which .eql? to the recursive
  object, if recursion is detected.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 13:32:24 +00:00
nobu 6f2efe84fb hash.c: detect recursion for all
* hash.c (rb_hash): detect recursion for all `hash' methods.  each
  `hash' methods no longer need to use rb_exec_recursive().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 13:18:30 +00:00
glass 437b8bc53b * array.c (rb_hash_rehash): use hash_alloc() instead of rb_hash_new().
[Bug #9187]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 11:19:06 +00:00
nobu d7de38ff62 * hash.c (w32_getenv): should be static.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 03:18:46 +00:00
usa ff9f9c6d84 * hash.c (getenv): fixed test failures introduced by r43950.
[ruby-core:58774] [Bug #9195] reported by phasis68 (Heesob Park).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-02 13:31:14 +00:00
glass ead0c5d356 * hash.c (rb_hash_rehash): make temporary st_table under the control
of GC. [Bug #9187]

* test/ruby/test_hash.rb: add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-02 12:59:31 +00:00
usa 6b1a58b9e6 * hash.c (getenv): use ANSI codepage version of getenv() for miniruby
on Windows.
  [ruby-core:58732] [Bug #9189] reported by phasis68 (Heesob Park).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-01 15:55:56 +00:00
glass 8efbe96231 * hash.c (rb_hash_to_a): specify array capa.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-01 05:39:38 +00:00
glass bfbe1b9b31 * hash.c (rb_hash_rehash): fix to free new st_table when exception
is raised in do_hash(). [Bug #9187]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-01 05:28:54 +00:00
glass 79e6336495 * st.c: add st_values() and st_values_check().
* include/ruby/st.h: add prototypes for above.

* hash.c (rb_hash_values): use st_values_check() for performance
 improvement if VALUE and st_data_t are compatible.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-28 08:39:16 +00:00
glass 78cfcbc657 * st.c (st_keys): fix not to use Qundef in st.c.
* include/ruby/st.h: define modified prototype.

* hash.c (rb_hash_keys): use modified st_keys().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-28 08:15:26 +00:00
glass 8c91dfb91b * st.c (st_keys): fix to use st_index_t for size of hash.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-27 16:36:44 +00:00
glass b426e1b1fa * st.c (st_keys): define st_keys(). it writes each key to buffer.
* hash.c (rb_hash_keys): use st_keys() for performance improvement
  if st_data_t and VALUE are compatible.

* st.h: define macro ST_DATA_COMPATIBLE_P() to predicate whether
  st_data_t and passed type are compatible.

* configure.in: check existence of builtin function to use in
  ST_DATA_COMPATIBLE_P().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-27 16:07:10 +00:00
tmm1 23178d1044 * gc.c (gc_page_sweep): Fix compile warning from last commit.
* hash.c (hash_aset_str): Re-use existing variable to avoid
  unnecessary pointer dereferencing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-27 06:24:37 +00:00
tmm1 0c3b3e9237 * hash.c (hash_aset_str): Use rb_fstring() to de-duplicate hash string
keys. Patch by Eric Wong. [Bug #8998] [ruby-core:57727]
* test/ruby/test_hash.rb (class TestHash): test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-27 05:28:55 +00:00
nobu 94f01c55df should not ignore the rest of recursive constructs
* array.c (rb_ary_hash): should not ignore the rest of recursive
  constructs.
* hash.c (rb_hash_hash): ditto.
* range.c (range_hash): ditto.
* struct.c (rb_struct_hash): ditto.
* test/-ext-/test_recursion.rb (TestRecursion): separate from
  test/ruby/test_thread.rb.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-26 17:20:16 +00:00
nobu d503381ce8 hash.c: cut off if recursion
* hash.c (rb_hash): cut off if recursion detected to get rid of stack
  overflow.  [ruby-core:58567] [Bug #9151]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-26 13:43:40 +00:00
nobu abdada2d85 hash.c: static internal functions
* hash.c (NOINSERT_UPDATE_CALLBACK): make both of noinsert and insert
  internal functions static.  and put semicolons for etags to find the
  following functions properly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-17 14:34:27 +00:00
tarui 28a1c4f33e * cont.c : Introdule ensure rollback mechanism. Please see below.
* internal.h (ruby_register_rollback_func_for_ensure): catch up above change.
	  Add rollback mechanism API.

	* vm_core.h (typedef struct rb_vm_struct): catch up above change.
	  Introdule ensure-rollback relation table.

	* vm_core.h (typedef struct rb_thread_struct): catch up above change.
	  Introdule ensure stack.

	* eval.c (rb_ensure): catch up above change.
	  Introdule ensure stack.

	* hash.c : New function for rollback ensure, and register it to
	  ensure-rollback relation table. [ruby-dev:47803] [Bug #9105]

	Ensure Rollback Mechanism:
	A rollback's function is a function to rollback a state before ensure's
	function execution.
	When the jump of callcc is across the scope of rb_ensure,
	ensure's functions and rollback's functions are executed appropriately
	for keeping consistency.

	Current API is unstable, and only internal use.

	ruby_register_rollback_func_for_ensure(ensure_func,rollback_func)
	This API create relation ensure's function to rollback's function.
	By registered rollback's function, it is executed When jumpping into
	corresponding rb_ensure scope.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-15 17:15:31 +00:00
tarui 9e96b1edea revert r43675 and r43683 without tests for applying rollback patch.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-15 17:08:52 +00:00
nobu e7d29c6cda hash.c: iteration level with reentering
* hash.c (hash_foreach_iter, hash_foreach_ensure, rb_hash_foreach):
  deal with iteration level when reentering by callcc.  temporary
  measure until rollback of ensure is introduced.  [ruby-dev:47807]
  [Bug #9105]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-15 13:21:38 +00:00
nobu 04c7fa0f3b hash.c: restore iter_lev
* hash.c (hash_foreach_ensure): restore iter_lev to the previous
  value, not just decrement.  [ruby-dev:47803] [Bug #9105]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-14 02:35:40 +00:00
nobu b0af0592fd hash.c, st.c: fix for ST_CHECK
* hash.c (foreach_safe_i, hash_foreach_iter): deal with error detected
  by ST_CHECK.
* st.c (st_foreach_check): call with non-error argument in normal case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-14 02:33:50 +00:00
zzak 078ae7dd80 * hash.c: [DOC] Adds an example for Hash#store
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-13 01:43:49 +00:00
tmm1 8f3934261a * internal.h: move common string/hash flags to include file.
* 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-11 09:39:13 +00:00
nobu b28ce966c7 st.c: revert st_keys
* st.c: revert st_keys() at r43238.  VALUE cannot be in st.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-10 16:28:56 +00:00
glass 026955e375 * st.c (st_keys): define st_keys() for performance improvement of
Hash#keys and Array#uniq.

* st.h: ditto.

* hash.c (rb_hash_keys): use st_keys().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-10 12:06:01 +00:00
nobu 9c6ea2f200 array.c: use rb_hash_values
* array.c (rb_ary_uniq): use rb_hash_values(), as well as the case no
  block is given.
* internal.h: define rb_hash_values() as internal API.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-08 07:11:15 +00:00
glass 41eb48b88d * array.c (rb_ary_uniq): use rb_hash_keys().
* internal.h: define rb_hash_keys() as internal API.

* hash.c (rb_hash_keys): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-08 04:56:50 +00:00
charliesome 0b991b6579 * hash.c (env_update): [DOC] fix expected output, should be 0 instead
of 10. Patch by @yakko. [GH-411]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-03 00:43:01 +00:00
glass 7eaee5b5e2 * hash.c (env_each_pair): do not call rb_assoc_new() if
it isn't needed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-23 03:17:38 +00:00
nobu 85995e88d4 hash.c: utility functions from ruby_setenv
* hash.c (invalid_envname, check_envname): extract utility functions
  from ruby_setenv().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-13 07:28:25 +00:00
ktsj 04f0de74dd * error.c, file.c, gc.c, hash.c, thread.c, variable.c, vm_eval.c, bin/erb:
$SAFE=4 is obsolete.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-18 10:36:51 +00:00
zzak 7c5dc219d0 * hash.c (rb_hash_aset): [DOC] Document key dup patch by @kachick
[Fixes GH-382] https://github.com/ruby/ruby/pull/382


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-14 17:34:40 +00:00
glass 3118deb3ee * hash.c (rb_hash_compare_by_id): add function prototype.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29 13:06:34 +00:00
glass cff03715ff * hash.c (rb_hash_compare_by_id): don't call rb_hash_rehash()
if self.compare_by_identity? == true.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29 12:57:40 +00:00
glass eb8f91866e * hash.c (rb_hash_assoc): performance improvement by replacing
compare function in RHASH(hash)->ntbl->type temporarily like r42224.
  it falls back to rb_hash_foreach() if st_lookup() doesn't find the key.

* test/ruby/test_hash.rb: add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29 12:39:21 +00:00
glass ef01a5a649 * hash.c (rb_hash_assoc): revert r42224. table->type->compare is
called only if hashes are matched.

* test/ruby/test_hash.rb: add a test to check using #== to compare.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29 11:24:08 +00:00
nobu be24b385ff ChangeLog: commit miss
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29 07:51:23 +00:00
glass 3f8e82b421 * hash.c (rb_hash_assoc): performance improvement by replacing
compare function in RHASH(hash)->ntbl->type temporarily.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29 05:58:36 +00:00
naruse f262909cba * hash.c (rb_hash_flatten): use NUM2INT to raise TypeError on 32bit
platform. it's introduced by r42039

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-20 20:44:49 +00:00
glass 852caed8a3 * hash.c (rb_hash_flatten): performance improvement by not using
rb_hash_to_a() to avoid array creation with rb_assoc_new().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 08:48:12 +00:00
glass b30eb0fa04 * hash.c (delete_if_i): use ST_DELETE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 13:59:53 +00:00
glass 7c1a2f6192 * hash.c (rb_hash_replace): performance improvement by using
st_copy().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 13:17:01 +00:00
nobu c9118e2a86 hash.c: key name in error message
* hash.c (env_fetch): Add key name to message on ENV.fetch KeyError,
  as well as Hash#fetch.  [ruby-core:56062] [Feature #8649]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 08:12:25 +00:00
glass b9d2960337 * hash.c (rb_hash_each_pair): performance improvement by using
rb_block_arity().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 04:38:50 +00:00
glass bc241235ac * hash.c (rb_hash_reject_bang): do not call rb_hash_foreach() if RHash
has ntbl and it is empty.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-12 02:35:16 +00:00
glass b9a9a02409 * hash.c (recursive_hash): use RHASH_SIZE() to check hash size.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-12 02:22:01 +00:00
glass 7a171aa8d1 * hash.c (rb_hash_size): use RHASH_SIZE().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11 15:25:31 +00:00
glass 76a400ff71 * hash.c (rb_hash_values): set array capa to RHASH_SIZE().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11 15:09:56 +00:00
glass c459495c77 * hash.c (rb_hash_keys): set array capa to RHASH_SIZE().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11 15:06:18 +00:00
nobu 5e2f227d21 intern.h: define rb_enumerator_size_func
* include/ruby/intern.h (rb_enumerator_size_func): define strict
  function declaration for rb_enumeratorize_with_size().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 13:43:22 +00:00
charliesome fff3589899 * compile.c (make_name_for_block): use PRIsVALUE in format string
instead of %s and RSTRING_PTR to protect objects from being garbage
  collected too soon
* encoding.c (str_to_encindex): ditto
* hash.c (rb_hash_fetch_m): ditto
* io.c (rb_io_reopen): ditto
* parse.y (reg_fragment_check_gen): ditto
* parse.y (reg_compile_gen): ditto
* parse.y (ripper_assert_Qundef): ditto
* re.c (rb_reg_raise): ditto
* ruby.c (set_option_encoding_once): ditto
* vm_eval.c (rb_throw_obj): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-24 11:31:21 +00:00
ko1 982fee4fcc * include/ruby/ruby.h, gc.c: rename macros and functions:
OBJ_WB_GIVEUP() -> OBJ_WB_UNPROTECT(),
  rb_obj_wb_giveup() -> rb_obj_wb_unprotect(),
  rb_gc_giveup_promoted_writebarrier() ->
  rb_gc_writebarrier_unprotect_promoted(),
* class.c, eval.c, hash.c: use OBJ_WB_UNPROTECT().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 21:54:10 +00:00
ko1 4223f00713 * include/ruby/ruby.h (OBJ_WRITE): cast to (VALUE *) for second
parameter `slot'. You don't need to write a cast (VALUE *) any more.
* class.c, compile.c, hash.c, iseq.c, proc.c, re.c, variable.c,
  vm.c, vm_method.c: remove cast expressions for OBJ_WRITE().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 19:52:40 +00:00
nobu 79031be880 hash.c: refine error message
* hash.c (ruby_setenv): refine error message so include the variable
  name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 05:31:41 +00:00
ko1 0f1df31bdf * hash.c: `st_update()' also has same issue of last fix.
write barriers at callback function are too early.
  All write barriers are executed after `st_update()'



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 21:29:30 +00:00
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
akr b23d9a8a63 * bignum.c (validate_integer_pack_format): Don't require a word order
flag if numwords is 1 or less.
  (absint_numwords_generic): Don't specify a word order for
  rb_integer_pack.

* hash.c (rb_hash): Ditto.

* time.c (v2w_bignum): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-11 14:40:16 +00:00
akr 0e8caa7d0f * bignum.c (rb_integer_pack): Returns sign instead of words.
(absint_numwords_generic): Follow the above change.
  (big2str_base_powerof2): Follow the above change.

* internal.h: Ditto.

* hash.c (rb_hash): Ditto.

* pack.c (pack_pack): Ditto.

* random.c (int_pair_to_real_inclusive): Ditto.
  (rand_init): Ditto.
  (random_load): Ditto.
  (limited_big_rand): Ditto.

* time.c (v2w_bignum): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 10:37:39 +00:00
akr 837392b452 * bignum.c (rb_integer_pack): numwords_allocated argument removed.
* internal.h (rb_integer_pack): Follow the above change.

* hash.c (rb_hash): Ditto.

* time.c (v2w_bignum): Ditto.

* pack.c (pack_pack): Ditto.

* random.c (int_pair_to_real_inclusive): Ditto.
  (rand_init): Ditto.
  (random_load): Ditto.
  (limited_big_rand): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-09 05:53:00 +00:00
akr e3bc7eec5f * hash.c (rb_hash): Use rb_integer_pack to obtain least significant
long integer.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 16:00:16 +00:00
nobu 6db56c86c9 fill rdocs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-02 03:12:04 +00:00
ko1 68f96f6c3c * hash.c: fix WB bug.
(1) Hash's key also needs WB.
  (2) callback parameter *key and *value of st_update() is not a
  storage of st_table itself (only local variable). So that
  OBJ_WRITE() is not suitable, especially for `!exsinting'.
  OBJ_WRITTEN() is used instead of OBJ_WRITE().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-29 01:38:52 +00:00
ko1 c4c821a7d7 * hash.c (rb_hash_tbl_raw), internal.h: added.
Returns st_table without shading hash.
* array.c: use rb_hash_tbl_raw() for read-only purpose.
* compile.c (iseq_compile_each): ditto.
* gc.c (count_objects): ditto.
* insns.def: ditto.
* process.c: ditto.
* thread.c (clear_coverage): ditto.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 16:19:04 +00:00
ko1 a20a14727f * hash.c, include/ruby/ruby.h: support WB protected hash.
* constify RHash::ifnone and make new macro RHASH_SET_IFNONE().
* insert write barrier for st_update().
* include/ruby/intern.h: declare rb_hash_set_ifnone(hash, ifnone).
* marshal.c (r_object0): use RHASH_SET_IFNONE().
* ext/openssl/ossl_x509name.c (Init_ossl_x509name): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 12:37:11 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
zzak 0dc6dcfb6a * hash.c: Hash[] and {} are not equivalent by @eam [Fixes GH-301]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 01:31:27 +00:00
charliesome 5d7b5481ca * benchmark/bm_hash_shift.rb: add benchmark for Hash#shift
* hash.c (rb_hash_shift): use st_shift if hash is not being iterated to
  delete element without iterating the whole hash.

* hash.c (shift_i): remove function

* include/ruby/st.h (st_shift): add st_shift function

* st.c (st_shift): ditto

[Bug #8312] [ruby-core:54524] Patch by funny-falcon

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-25 05:03:30 +00:00
hsbt da91385f2c fix ENV.to_a rdoc example by @benolee [fix GH-288]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-16 06:28:35 +00:00
marcandre a6d08b450c * array.c: Fix rdoc for flatten!
* hash.c: Correct rdoc for reject!

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23 20:17:20 +00:00
charliesome e45e06410d * hash.c (env_reject_bang): hide keys array from ObjectSpace
* hash.c (env_select_bang): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-06 13:46:26 +00:00
drbrain 0051369ba3 * hash.c (rb_env_size): Restored documentation for ENV.size
* lib/drb/drb.rb:  Documented DRb::DRb#run.

* lib/erb.rb (class ERB):  Improved documentation of ERb.

* transcode.c:  Documented Encoding::Converter constants.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-26 03:58:33 +00:00
zzak 663613a993 * hash.c (rb_hash_update): Revert documentation from r38672
See: https://github.com/ruby/ruby/pull/228#issuecomment-11791013


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-01 17:28:47 +00:00
zzak 1290747cfb * hash.c (rb_hash_update): Documentation for Hash#merge and shallow
copies Patch by Yorick Peterse [Fixes Github #228]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-01 17:17:28 +00:00
nobu be7bf5aa0c adjust style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29 12:22:04 +00:00
charliesome af35f2a61d * configure.in: check for the whether crt_externs.h is present when compiling
for darwin (this header is missing in the iOS SDK)
* eval_intern.h: check HAVE_CRT_EXTERNS_H before including crt_externs.h, if
  not defined, include missing/crt_externs.h instead
* hash.c: ditto
* missing/setproctitle.c: ditto
* missing/crt_externs.h: declare _NSGetEnviron() function and define environ
  for iOS

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-28 14:23:25 +00:00
nobu 66fd9d44d8 adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01 15:25:28 +00:00
tenderlove 4c740bae97 * probes.d: add DTrace probe declarations. [ruby-core:27448]
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe.

* compile.c (rb_insns_name): allowing DTrace probes to access
  instruction sequence name.

* Makefile.in: translate probes.d file to appropriate header file.

* common.mk: declare dependencies on the DTrace header.

* configure.in: add a test for existence of DTrace.

* eval.c (setup_exception): add a probe for when an exception is
  raised.

* gc.c: Add DTrace probes for mark begin and end, and sweep begin and
  end.

* hash.c (empty_hash_alloc): Add a probe for hash allocation.

* insns.def: Add probes for function entry and return.

* internal.h: function declaration for compile.c change.

* load.c (rb_f_load): add probes for `load` entry and exit, require
  entry and exit, and wrapping search_required for load path search.

* object.c (rb_obj_alloc): added a probe for general object creation.

* parse.y (yycompile0): added a probe around parse and compile phase.

* string.c (empty_str_alloc, str_new): DTrace probes for string
  allocation.

* test/dtrace/*: tests for DTrace probes.

* vm.c (vm_invoke_proc): add probes for function return on exception
  raise, hash create, and instruction sequence execution.

* vm_core.h: add probe declarations for function entry and exit.

* vm_dump.c: add probes header file.

* vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on
  function entry and return.

* vm_exec.c: expose instruction number to instruction name function.

* vm_insnshelper.c: add function entry and exit probes for cfunc
  methods.

* vm_insnhelper.h: vm usage information is always collected, so
  uncomment the functions.

12 19:14:50 2012  Akinori MUSHA  <knu@iDaemons.org>

* configure.in (isinf, isnan): isinf() and isnan() are macros on
  DragonFly which cannot be found by AC_REPLACE_FUNCS().  This
  workaround enforces the fact that they exist on DragonFly.

12 15:59:38 2012  Shugo Maeda  <shugo@ruby-lang.org>

* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo),
  vm_insnhelper.c (vm_search_method): revert r37616 because it's too
  slow.  [ruby-dev:46477]

* test/ruby/test_refinement.rb (test_inline_method_cache): skip
  the test until the bug is fixed efficiently.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12 21:52:12 +00:00
nobu 5051186a0b hash.c: warn for wrong elements
* hash.c (rb_hash_s_create): just warn for wrong elements now.
  [ruby-dev:46440] [Bug #7300]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-11 06:39:08 +00:00
nobu 5a5a86cc52 hash.c: refine error messages
* hash.c (rb_hash_s_create): refine error messages.
* error.c (rb_builtin_class_name): share for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-11 06:38:17 +00:00
marcandre 17c0aff0d6 * hash.c: Support for enumerators created by ENV:
each, each_value, ...
  [Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:13:48 +00:00
marcandre 19ed71c8d0 * hash.c: Support for enumerators created by Hash:
delete_if, reject!, ...
  [Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:13:33 +00:00
shirosaki b56a2afc14 Index $LOADED_FEATURES so that require isn't so slow
* load.c (rb_feature_p, rb_provide_feature): index $LOADED_FEATURES
  so that require isn't so slow.

* load.c (rb_provide_feature, get_loaded_features_index): ensure
  that $LOADED_FEATURES entries are frozen strings.  The user
  must mutate $LOADED_FEATURES itself rather than its individual
  entries.

* load.c (reset_loaded_features_snapshot): add a new function to reset
  vm->loaded_features_snapshot.

* load.c (get_loaded_features_index_raw): add a new function to get
  the loaded-features index.

* load.c (features_index_add_single): add a new function to add to the
  loaded-features index a single feature.

* load.c (features_index_add): add a new function to add to the
  loaded-features index all the required entries for `feature`.

* vm_core.h (rb_vm_struct): add fields.

* vm.c (rb_vm_mark): mark new fields.

* include/ruby/intern.h (rb_hash_clear): declare function.

* hash.c (rb_hash_clear): make function non-static.
  Patch by Greg Price.
  [ruby-core:47970] [Bug #7158]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-05 15:27:01 +00:00
zzak 63e9bc50f5 * hash.c (rb_hash_delete): Correct grammar
Patch by Glenn Oppegard
  [Fixes #208 Github]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-03 02:45:15 +00:00
nari c3a46d6aca * include/ruby/ruby.h: add C APIs.
VALUE rb_newobj_of(VALUE klass, VALUE flags)
  #define NEWOBJ_OF(obj,type,klass,flags)
  These allow to change a allocation strategy depending on klass
  or flags.

* gc.c: ditto

* array.c: use new C API.
* bignum.c: ditto
* class.c: ditto
* complex.c: ditto
* ext/socket/ancdata.c: ditto
* ext/socket/option.c: ditto
* hash.c: ditto
* io.c: ditto
* marshal.c: ditto
* numeric.c: ditto
* object.c: ditto
* random.c: ditto
* range.c: ditto
* rational.c: ditto
* re.c: ditto
* string.c: ditto
* struct.c: ditto
  [Feature #7177][Feature #7047]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20 06:57:51 +00:00
tenderlove fb03eb91fe * hash.c (initialize_copy): unset the default proc if there isn't one
for the target hash, call to_hash, check frozen status.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-19 21:20:33 +00:00
tenderlove a34a3c2caa * hash.c (initialize_copy): duping should rehash the hash.
* test/ruby/test_hash.rb: added a test to ensure rehash.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-18 00:24:00 +00:00
tenderlove b3803cc49a * hash.c (initialize_copy): copy the underlying st_table on dup,
rather than copying the hash key by key. [ruby-core:48009]

* test/ruby/test_hash.rb: relevant tests for initialize_copy

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-16 21:33:59 +00:00
nobu 8d6add973e hash.c: raise on invalid input
* hash.c (rb_hash_s_create): raise an exception, when input elements
  are not one or two elements arrays.  [ruby-core:39945] [Bug #5406]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-14 08:08:15 +00:00
nobu b0dd250dc9 use RB_TYPE_P() instead of comparison of TYPE()
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-23 07:13:21 +00:00
nobu 770ddcdfe0 * hash.c, object.c, struct.c, lib/ostruct.rb: add to_h methods.
[Feature #6276]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-24 03:46:55 +00:00
naruse 62c9ecfa12 Revert r35339-35343 because of no tests.
* hash.c: Alias ENV.to_h to ENV.to_hash [ref #6276]

* lib/ostruct.rb: Add OpenStruct#to_h [Feature #6276]

* struct.c: Add Struct#to_h [Feature #6276]

* object.c: Add NilClass#to_h [Feature #6276]

* hash.c: Add Hash#to_h [Feature #6276]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-18 03:59:15 +00:00
marcandre fc7676fcd6 * hash.c: Alias ENV.to_h to ENV.to_hash [ref #6276]
[rubyspec:6587eead7cd1]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-16 03:16:40 +00:00
marcandre f92be2c01a * hash.c: Add Hash#to_h [Feature #6276]
[rubyspec:84b7fe3f24d2]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-16 03:15:42 +00:00
nobu 723bfaba59 * hash.c (no_new_key): moved test to raise outside.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-13 11:30:39 +00:00
naruse 99d38f82e0 * hash.c (inspect_i): keep string's coderange.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-13 08:39:13 +00:00
nobu 2d74f3e682 * hash.c (rb_hash_aset, rb_hash_update, rb_hash_update_by): use
st_update() to reduce evaluation of hash values.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-13 06:26:53 +00:00
nobu e2aaf978b5 * hash.c: use RHASH_ITER_LEV(), not iter_leve directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-12 06:10:31 +00:00
marcandre 6b18a8c2e9 * hash.c (rb_hash_set_default_proc): Accept nil, patch by Run Paint
[Feature #4234]

* test/ruby/test_hash.rb: test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-09 04:07:53 +00:00
nobu 160d02d830 * hash.c (hash_default_value): extract from rb_hash_aref(), to be
shared with rb_hash_shift(), so that overriding Hash#default
  will be respected.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-31 05:23:01 +00:00
nobu e8a1874c19 * hash.c: do not allocate st_table when it is not necessary.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-31 05:16:04 +00:00
nobu a3626110d9 * hash.c: remove unnecessary checks for Qundef in hash iterations.
since hash use st_foreach_check for iterations, such checks are
  needless.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-31 04:20:45 +00:00
nobu 197627354e * st.c (st_foreach_check): remove the entry by replacing with never
when ST_DELETE.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-30 22:53:26 +00:00
nobu d0380e2e56 * hash.c (st_foreach_safe): since table is not for VALUE, Qundef is
not special value, so use 0 instead.  therefore this function can be
  applied to only st_table which 0 is invalid as keys, e.g., IDs.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-30 22:47:33 +00:00
nobu 4fa3236600 * hash.c: Qundef cannot be passed from st_foreach_check().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-30 22:44:33 +00:00
nobu 4b3a1f77e1 * hash.c, marshal.c, object.c, variable.c: fix callback argument types
of iterators.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-30 22:40:54 +00:00
usa f59caa2950 * hash.c (env_str_new, rb_f_getenv, env_fetch): use rb_str_conv_enc()
instead of rb_str_encode() to simplify the code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 04:49:20 +00:00
usa fcaee4bd64 * win32/win32.c, include/ruby/win32.h (rb_w32_ugetenv): new API to
accept and to return UTF-8 strings.

* win32/win32.c (rb_w32_getenv): follow above change.

* win32/win32.c (rb_w32_get_environ): returns UTF-8 environment area.

* hash.c (env_str_new, rb_f_getenv, env_fetch): follow above changes.
  [Bug #5570] [ruby-core:40737]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 03:57:02 +00:00
marcandre 7316302483 * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* array.c: Use rb_check_arity / rb_error_arity

* class.c: ditto

* enumerator.c: ditto

* eval.c: ditto

* file.c: ditto

* hash.c: ditto

* numeric.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* re.c: ditto

* signal.c: ditto

* string.c: ditto

* struct.c: ditto

* transcode.c: ditto

* vm_eval.c: ditto

* vm_insnhelper.c: ditto & implementation of rb_error_arity

* test/ruby/test_arity.rb: tests for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 21:10:34 +00:00
nobu a73d958c33 * st.c: add st_foreach_check for fixing iteration over packed table
and st_delete_safe.  patched by Sokolov Yura at
  https://github.com/ruby/ruby/pull/84


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-10 14:52:19 +00:00
ktsj b212b84fc1 * hash.c: remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-04 13:59:23 +00:00
drbrain 0e0286404f * hash.c (Init_Hash): Add section on how objects are used as Hash keys
and how to use custom classes as Hash keys.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-23 23:03:39 +00:00
nobu ca9b0f56fc * hash.c (rb_any_hash): treat Qundef like as other special constants.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-21 11:23:50 +00:00
nobu bc3b4ddddd * hash.c (hash_foreach_iter): fix signature.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-21 11:22:49 +00:00
nobu 413f24d3b0 * whitespace cleanup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-04 07:19:23 +00:00
akr 2bb5441808 * complex.c: use "__sun" instead of "__sun__" to detect SunOS.
* math.c: ditto.

* hash.c: ditto.

* atomic.h: ditto.

* ext/io/wait/wait.c: ditto.

[ruby-dev:44693]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-24 14:57:08 +00:00
nobu 12c497dcf6 * hash.c (identhash): share with type_numhash.
* st.c (st_hashtype_num): rename from type_numhash.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-18 14:28:58 +00:00
drbrain 6f8f555d2f * hash.c (Init_Hash): Improve Hash documentation. Patch by Alvaro
Pereyra Rabanal.  [Ruby 1.9 - Bug #5405]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-04 20:57:07 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
nobu 86bbfdadf3 * hash.c (recursive_hash): hash value of emptied hash should be
equal to an empty hash.  [ruby-core:38650]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-02 03:03:18 +00:00
drbrain b57a0d44f9 * hash.c: Document ENV
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30 00:20:15 +00:00
drbrain 926301969f * math.c: Attach documentation for Math.
* object.c:  Document NIL, TRUE, FALSE.
	* io.c:  Improve grammar in ARGF comment.  Document STDIN/OUT/ERR.
	  Document ARGF global constant.
	* lib/rake:  Hide deprecated toplevel constants from RDoc (import from
	  rake trunk).
	* lib/thwait.rb:  Document ThWait.
	* lib/mathn.rb:  Hide Math redefinition from RDoc
	* lib/sync.rb:  Add a basic comment for Sync_m, Synchronizer_m, Sync,
	  Synchronizer.
	* parse.y:  Document SCRIPT_LINES__.
	* hash.c:  Document ENV class and global constant.
	* vm.c:  Document TOPLEVEL_BINDING.
	* version.c:  Document RUBY_* constants.
	* ruby.c:  Document DATA and ARGV.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-29 03:09:34 +00:00
naruse 145fccbd42 * hash.c (rb_hash_reject): add documentation that Hash#reject
without block returns enumerator.
  patched by Michael Edgar [Bug #4847] [ruby-core:36800]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-26 15:45:47 +00:00
akr 5ed8c08aa0 * eval.c, hash.c, load.c, proc.c, range.c, thread.c, time.c: don't
declare internal functions.

* internal.h, vm_core.h: declare internal functions.

* array.c: include internal.h.

* common.mk: update dependency for array.o.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 08:26:19 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
drbrain f6809f61d6 * hash.c (key_i): Change rdoc from "the first occurence" to "an
occurrence" since first occurrence is not a specification of
	  Hash#key.  [Ruby 1.9 - Bug #4760]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 22:35:59 +00:00
drbrain 317e2a5021 * hash.c: Improve documentation of Hash#key. Patch by Utkarsh
Kukreti.  [Ruby 1.9 - Bug #4760]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-22 23:37:03 +00:00
arton 11e4052295 * hash.c (ruby_setenv): check env process block size with OS ver.
* win32/win32.c: export rb_w32_osver for above patch.
* include/ruby/win32.h: declare rb_w32_osver for Win32 Libs.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-19 16:33:59 +00:00
arton bdc8f4fca9 * hash.c: refactoring prior patch (getenvsize win32 specfic function).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-19 10:00:51 +00:00
arton 5281610f91 * hash.c (ruby_setenv): calculate total env block size for win32.
* test/ruby/test_env.rb: add test for above patch.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-19 09:28:49 +00:00
arton 812550b977 * hash.c (ruby_setenv): checking with max process environment block size fow Win32.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-19 08:10:08 +00:00
usa 45f59656ae * hash.c (ruby_setenv): MSDN says that Windows XP or earlier limits
the total size of environment block to 5,120 chars.  and on such
  OS, putenv() causes SEGV.  So, ruby should limit the size of an
  environment variable to 5,120 bytes for workaround.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-08 07:52:19 +00:00
naruse 7798b9667e * hash.c (inspect_i): copy the encoding of the first key as
an initial encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-15 07:08:20 +00:00
nobu 46142e472f * hash.c (rb_hash_fetch_m): use useful message for longer key, not a
nonsense id value.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-30 04:03:19 +00:00
kosaki 1e60af4d67 * hash.c (rb_hash_fetch_m): add GC guard to prevent intermediate
variable from GC.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-27 17:36:32 +00:00
nobu 79654f3fd3 * hash.c (hash_i): return different values for inverse hash.
[ruby-core:34334]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-11 23:37:15 +00:00
akr 7b5e72c3a9 * hash.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-14 22:18:39 +00:00
nobu 2d4b0d6261 * hash.c (rb_hash_update_by): new API for Hash#update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-04 02:21:53 +00:00
nobu 23e8deaf0d * array.c, gc.c, hash.c, object.c, string.c, struct.c,
transcode.c, variable.c, vm.c, vm_insnhelper.c, vm_method.c:
  replace calls to rb_error_frozen() with rb_check_frozen().  a
  patch from Run Paint Run Run at [ruby-core:32014]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-24 08:14:05 +00:00
nobu 671b498070 Commit miss.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-19 03:25:29 +00:00
nobu 12cbb58819 * test/ruby/test_sprintf.rb: fix ML ref. [ruby-core:32848]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-19 03:22:03 +00:00
ko1 261661517a * hash.c (rb_hash_aref): skip calling "default" method
if it is not neede for speed-up.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-15 15:10:17 +00:00
nobu d410639a6d * compile.c (iseq_build_body), error.c (set_syserr, get_syserr),
(syserr_initialize), gc.c (define_final, rb_gc_copy_finalizer),
  (run_final), hash.c (rb_hash_aref, rb_hash_lookup2),
  (rb_hash_fetch_m, rb_hash_clear, rb_hash_aset, eql_i),
  iseq.c (iseq_load, iseq_data_to_ary), marshal.c (r_symlink),
  thread.c (rb_thread_local_aref),
  variable.c (generic_ivar_remove, ivar_get, rb_const_get_0),
  (rb_cvar_get), vm.c (rb_vm_check_redefinition_opt_method),
  vm_insnhelper.c (vm_get_ev_const), vm_method.c (remove_method),
  ext/iconv/iconv.c (map_charset): use st_data_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 14:47:23 +00:00
usa 85bcd25877 * hash.c (ruby_setenv): workaround for old Windows. a patch from
Heesob Park. [ruby-core:32353]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-30 01:57:17 +00:00
nobu da47bbd1db * hash.c (ruby_setenv): raise if putenv and SetEnvironmentVariable
failed, because of the restriction of the size on Windows.
  based on a patch from Peter Weldon at [ruby-core:32304].  fix:
  Bug#3812, [ruby-core:32250]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-11 07:47:44 +00:00
nobu b80d5f14df * hash.c (rb_check_hash_type): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-03 12:01:13 +00:00
marcandre c1ecff1b1e * hash.c: Documentation: change => in call-seq to ->.
* enum.c: Documentation: whitespace fix for r27865

* error.c: ditto

* file.c: ditto

* io.c: ditto

* load.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:31:22 +00:00