summaryrefslogtreecommitdiff
path: root/struct.c
AgeCommit message (Collapse)Author
2023-08-15[DOC] Improve doc guide compliance (#8221)Burdette Lamar
2023-07-13[Feature #19730] Remove transient heapPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/7942
2023-07-13[Feature #19757] Add new API `rb_data_define`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/8066
2023-06-23Prefer `0` over `NULL` as function pointersNobuyoshi Nakada
SunC warns use of `NULL`, pointer to data as function pointers. Notes: Merged: https://github.com/ruby/ruby/pull/7972 Merged-By: nobu <nobu@ruby-lang.org>
2023-06-12When alloc size is too large, only allocate structMatt Valentine-House
Notes: Merged: https://github.com/ruby/ruby/pull/7933
2023-06-05Implement Struct on VWAPeter Zhu
The benchmark results show that this feature has either a positive or no impact on performance. The memory usage is also mostly unchanged, except in hexapdf, where there is a decrease in RSS. -------------- ----------- ---------- --------- ----------- ---------- --------- -------------- ------------- bench master (ms) stddev (%) RSS (MiB) branch (ms) stddev (%) RSS (MiB) branch 1st itr master/branch activerecord 70.8 2.2 56.0 71.7 2.2 56.0 0.99 0.99 erubi_rails 20.5 13.6 94.7 20.5 14.3 94.2 0.93 1.00 hexapdf 2541.0 0.7 212.8 2544.4 0.7 203.4 1.00 1.00 liquid-c 65.6 0.3 38.9 65.3 0.3 38.9 1.01 1.01 liquid-compile 63.7 0.3 34.6 61.1 0.2 34.6 1.04 1.04 liquid-render 163.1 0.1 37.1 163.3 0.1 37.1 1.00 1.00 mail 139.3 0.1 50.5 137.0 0.1 50.1 0.99 1.02 psych-load 2065.7 0.1 36.9 2068.2 0.1 37.3 1.00 1.00 railsbench 2034.6 0.5 103.9 2031.9 0.5 103.8 1.02 1.00 ruby-lsp 65.3 3.1 89.8 66.2 3.0 89.7 1.01 0.99 sequel 73.2 1.0 40.3 73.4 1.0 40.3 1.00 1.00 -------------- ----------- ---------- --------- ----------- ---------- --------- -------------- ------------- Notes: Merged: https://github.com/ruby/ruby/pull/7871
2023-04-24Allow anonymous memberless StructJeremy Evans
Previously, named memberless Structs were allowed, but anonymous memberless Structs were not. Fixes [Bug #19416] Notes: Merged: https://github.com/ruby/ruby/pull/7587
2023-04-06[Feature #19474] Refactor NEWOBJ macrosMatt Valentine-House
NEWOBJ_OF is now our canonical newobj macro. It takes an optional ec Notes: Merged: https://github.com/ruby/ruby/pull/7393
2023-03-08[DOC] Fix broken link Data#deconstruct_keysSampat Badhe
Notes: Merged: https://github.com/ruby/ruby/pull/7463 Merged-By: nobu <nobu@ruby-lang.org>
2023-02-28Fix spelling (#7405)John Bampton
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2023-02-19Remove (newly unneeded) remarks about aliasesBurdetteLamar
2023-02-14[Bug #19259] `Data#with` should call `initialize` methodNobuyoshi Nakada
2023-02-03Avoid using OBJ_WB_UNPROTECTJean Boussier
Not that it makes a big difference here, but it's just unecessary. Notes: Merged: https://github.com/ruby/ruby/pull/7241
2023-02-03[DOC] Fix call-seq of Struct.new (#7246)Kouhei Yanagita
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-12-28[DOC] Fix call-seq for Data.defineKouhei Yanagita
Notes: Merged: https://github.com/ruby/ruby/pull/7038
2022-12-23Docs: Update Struct docs about keyword initializationzverok
Notes: Merged: https://github.com/ruby/ruby/pull/6985
2022-12-21Add copy with changes functionality for Data objects (#6766)Ufuk Kayserilioglu
Implements [Feature #19000] This commit adds copy with changes functionality for `Data` objects using a new method `Data#with`. Since Data objects are immutable, the only way to change them is by creating a copy. This PR adds a `with` method for `Data` class instances that optionally takes keyword arguments. If the `with` method is called with no arguments, the behaviour is the same as the `Kernel#dup` method, i.e. a new shallow copy is created with no field values changed. However, if keyword arguments are supplied to the `with` method, then the copy is created with the specified field values changed. For example: ```ruby Point = Data.define(:x, :y) point = Point.new(x: 1, y: 2) point.with(x: 3) # => #<data Point x: 3, y: 2> ``` Passing positional arguments to `with` or passing keyword arguments to it that do not correspond to any of the members of the Data class will raise an `ArgumentError`. Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-12-02[Feature #19163] Marshal-loaded Data object also should be frozenNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6843
2022-12-02[Feature #19163] Data object should be frozenNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6843
2022-11-30Use RTEST and add test for GH-6832Alan Wu
Technically we shouldn't see Qfalse now, but RTEST also compiles down to just one branch anyways. Pretty contrived issue, but easy to fix. Notes: Merged: https://github.com/ruby/ruby/pull/6832
2022-11-30struct.c (struct_ivar_get): add conditional for potential Qnil returned by ↵Zack Deveau
rb_class_superclass struct_ivar_get recently started using rb_class_superclass to resolve super instead of RCLASS_SUPER. This change made Qnil a possible case we need to return from within the struct_ivar_get for loop. Notes: Merged: https://github.com/ruby/ruby/pull/6832
2022-11-16Using UNDEF_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/6721
2022-10-06fix Data docs (#6497)Yuri Smirnov
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-10-03Cannot `define` from defined `Data` class againNobuyoshi Nakada
2022-10-01Use the dedicated function to check arityNobuyoshi Nakada
2022-10-01Fix an out of bound accessNobuyoshi Nakada
2022-10-01Do not define the method only for RDocNobuyoshi Nakada
`Data.members` fails an assertion.
2022-09-30Add Data class implementation: Simple immutable value objectVictor Shepelev
Notes: Merged: https://github.com/ruby/ruby/pull/6353 Merged-By: nobu <nobu@ruby-lang.org>
2022-09-09[DOC] Update `Struct#new` behavior with `keyword_init: true`Nobuyoshi Nakada
2022-07-26Rename rb_ary_tmp_new to rb_ary_hidden_newPeter Zhu
rb_ary_tmp_new suggests that the array is temporary in some way, but that's not true, it just creates an array that's hidden and not on the transient heap. This commit renames it to rb_ary_hidden_new. Notes: Merged: https://github.com/ruby/ruby/pull/6180
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://github.com/ruby/ruby/pull/6094
2022-05-26Don't attempt to read ivars on T_ICLASS in struct (#5664)John Hawthorn
Notes: Merged-By: jhawthorn <john@hawthorn.email>
2022-04-13[ci skip] Fix docsPeter Zhu
2022-03-30Repaired What's Here sections for Range, String, Symbol, Struct (#5735)Burdette Lamar
Repaired What's Here sections for Range, String, Symbol, Struct. Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-03-17A positional Hash is not keyword arguments [Bug #18632]Nobuyoshi Nakada
2022-02-12[DOC] Simplify operator method referencesNobuyoshi Nakada
2022-02-07[DOC] Use RDoc link style for links in the same class/modulePeter Zhu
I used this regex: (?<=\[)#(?:class|module)-([A-Za-z]+)-label-([A-Za-z0-9\-\+]+) And performed a global find & replace for this: rdoc-ref:$1@$2 Notes: Merged: https://github.com/ruby/ruby/pull/5530
2022-02-07[DOC] Use RDoc link style for links to other classes/modulesPeter Zhu
I used this regex: ([A-Za-z]+)\.html#(?:class|module)-[A-Za-z]+-label-([A-Za-z0-9\-\+]+) And performed a global find & replace for this: rdoc-ref:$1@$2 Notes: Merged: https://github.com/ruby/ruby/pull/5530
2022-02-06Improve links to labels in string.c and struct.c (#5531)Burdette Lamar
Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2021-12-26Initialize Struct by calling with keyword argumentsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5348
2021-12-25Fix typos [ci skip]Kazuhiro NISHIYAMA
2021-12-24Fix StructClass:: class method docszverok
Notes: Merged: https://github.com/ruby/ruby/pull/5279
2021-11-20`struct_pos_num` is no longer usedNobuyoshi Nakada
2021-11-19optimize `Struct` getter/setterKoichi Sasada
Introduce new optimized method type `OPTIMIZED_METHOD_TYPE_STRUCT_AREF/ASET` with index information. Notes: Merged: https://github.com/ruby/ruby/pull/5131
2021-10-25[DOC] Fix code markup [ci skip]Nobuyoshi Nakada
Code markup in RDoc must not be concatenated with anothr word.
2021-10-03Using NIL_P macro instead of `== Qnil`S.H
Notes: Merged: https://github.com/ruby/ruby/pull/4925 Merged-By: nobu <nobu@ruby-lang.org>
2021-09-27Enhanced RDoc for Struct (#4895)Burdette Lamar
Revises introductory material. Adds section "What's Here". Adds previously missing documentation for method #deconstruct_keys. Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2021-09-24Enhanced RDoc for Struct (#4891)Burdette Lamar
Treats: #values_at #select #== #hash #eql? #size #dig Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2021-09-24Enhanced RDoc for Struct (#4890)Burdette Lamar
Treated: #each #each_pair #inspect #to_a #to_h #[] #[]= Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2021-09-23Enhance RDoc for Struct (#4885)Burdette Lamar
Treats #members and ::new. Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>