ruby/ext/date
eileencodes d25b74b32c Resize arrays in `rb_ary_freeze` and use it for freezing arrays
While working on a separate issue we found that in some cases
`ary_heap_realloc` was being called on frozen arrays. To fix this, this
change does the following:

1) Updates `rb_ary_freeze` to assert the type is an array, return if
already frozen, and shrink the capacity if it is not embedded, shared
or a shared root.
2) Replaces `rb_obj_freeze` with `rb_ary_freeze` when the object is
always an array.
3) In `ary_heap_realloc`, ensure the new capa is set with
`ARY_SET_CAPA`. Previously the change in capa was not set.
4) Adds an assertion to `ary_heap_realloc` that the array is not frozen.

Some of this work was originally done in
https://github.com/ruby/ruby/pull/2640, referencing this issue
https://bugs.ruby-lang.org/issues/16291. There didn't appear to be any
objections to this PR, it appears to have simply lost traction.

The original PR made changes to arrays and strings at the same time,
this PR only does arrays. Also it was old enough that rather than revive
that branch I've made a new one. I added Lourens as co-author in addtion
to Aaron who helped me with this patch.

The original PR made this change for performance reasons, and while
that's still true for this PR, the goal of this PR is to avoid
calling `ary_heap_realloc` on frozen arrays. The capacity should be
shrunk _before_ the array is frozen, not after.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
Co-Authored-By: methodmissing <lourens@methodmissing.com>
2024-07-02 10:34:23 -07:00
..
lib [ruby/date] Bump up 3.3.4 2023-11-07 04:16:02 +00:00
date.gemspec [ruby/date] Provide a 'Changelog' link on rubygems.org/gems/date 2023-12-25 21:12:49 +09:00
date_core.c Resize arrays in `rb_ary_freeze` and use it for freezing arrays 2024-07-02 10:34:23 -07:00
date_parse.c [ruby/date] Use locale insensitive casecmp 2024-06-24 15:36:56 +00:00
date_strftime.c [ruby/date] Make %v strftime flag use uppercase month 2021-09-28 17:34:26 +09:00
date_strptime.c [ruby/date] Use locale insensitive casecmp 2024-06-24 15:36:56 +00:00
date_tmx.h ext/date: constify 2016-06-08 01:09:21 +00:00
depend ruby tool/update-deps --fix 2024-04-27 21:55:28 +09:00
extconf.rb [ruby/date] Deprecate the unintentional ability to parse `Symbol` 2022-02-25 19:57:50 +09:00
prereq.mk [ruby/date] Use gperf 3.1 to generate ANSI-C code 2024-06-24 15:36:55 +00:00
update-abbr [ruby/date] Honor timezones from timeanddate.com 2020-11-12 21:34:54 +09:00
zonetab.h [ruby/date] Update zonetab.h at 2024-06-26 2024-06-26 10:01:21 +00:00
zonetab.list [ruby/date] Use `strncasecmp` 2024-06-24 15:36:56 +00:00