Yukihiro "Matz" Matsumoto
a6a0346e1c
mruby-os-memsize: support Set class
2025-06-24 13:56:07 +09:00
Yukihiro "Matz" Matsumoto
132561418b
mruby-set: update Set class to use struct RSet not struct RData
2025-06-24 13:45:14 +09:00
google-labs-jules[bot]
dfd7251223
Refactor: Improve Set GC marking and freeing
...
This commit addresses feedback on the initial Set GC marking implementation.
Changes include:
- Renamed set marking function to `mrb_gc_mark_set` and updated its
return type to `size_t`.
- Introduced an explicit `mrb_gc_free_set` function for Set objects.
- Updated `gc_mark_children` to use the new mark function signature.
- Added an explicit `case MRB_TT_SET:` in `obj_free` to call `mrb_gc_free_set`.
- Adjusted `set_get_khash` in `mruby-set` to work with `MRB_TT_SET` directly,
rather than relying on `mrb_data_get_ptr`.
- Corrected type checks in `set_init_copy` to use `MRB_TT_SET`.
- Updated function prototypes in internal headers and stubs in mrbc.
2025-06-24 04:02:41 +00:00
Yukihiro "Matz" Matsumoto
4e08fae75a
mruby-compiler: add comprehensive comments to codegen.c
2025-06-24 09:50:37 +09:00
Yukihiro "Matz" Matsumoto
84a983c847
backtrace.c: add macros for clarity
2025-06-24 09:49:37 +09:00
Yukihiro Matz Matsumoto
dcd661efb8
File.basename: add support for suffix removal and enhance tests
2025-06-23 22:49:43 +00:00
Yukihiro "Matz" Matsumoto
791b374155
khash.h: reduce KHASH_DEFAULT_SIZE from 32 to 8
2025-06-23 17:07:31 +09:00
Yukihiro "Matz" Matsumoto
c152f3a79a
mruby-set: add comprehensive tests for Set operations: +, -, &
2025-06-23 17:07:31 +09:00
Yukihiro "Matz" Matsumoto
18b45c7ab5
mruby-set: change string representation from #<Set: {1}> to Set[1]
2025-06-23 17:07:31 +09:00
Yukihiro "Matz" Matsumoto
561a3eac82
mruby-set: make eql? an alias of == method
2025-06-23 17:07:30 +09:00
Yukihiro "Matz" Matsumoto
20b32531ea
mruby-set: Fix memory leak in Set#flatten! and simplify implementation
...
- Remove circular reference check in favor of max depth check only
- Fix memory leak by properly handling errors in set_flatten_bang
- Simplify code by reducing variables and unifying error handling
2025-06-23 17:07:30 +09:00
Yukihiro "Matz" Matsumoto
9d739cdad8
mruby-set: use set_is_set extensively
2025-06-23 17:07:30 +09:00
Yukihiro "Matz" Matsumoto
f47609574a
mruby-set: remove some AI generated work-log comments
2025-06-23 17:07:30 +09:00
Yukihiro "Matz" Matsumoto
ea0ceff7fb
mruby-set: implement Set#flatten and flatten! in C
...
The code is generated by Cursor.
2025-06-23 17:07:30 +09:00
Yukihiro "Matz" Matsumoto
73c61e4a60
mruby-set: optimize inspect/to_s to avoid intermediate array
2025-06-23 17:07:29 +09:00
Yukihiro "Matz" Matsumoto
e2982bdb57
mruby-set: optimize join method to avoid intermediate array
2025-06-23 17:07:29 +09:00
Yukihiro "Matz" Matsumoto
0430f1e9b8
mruby-set: optimize eql? by checking fast path
2025-06-23 17:07:29 +09:00
Yukihiro "Matz" Matsumoto
d7a0d5687e
mruby-set: optimize equal by checking fast path
2025-06-23 17:07:29 +09:00
Yukihiro "Matz" Matsumoto
83fc43e71d
mruby-set: improve Set#hash by using FNV-1 hashing
2025-06-23 17:07:29 +09:00
Yukihiro "Matz" Matsumoto
3a5d0a1840
mruby-set: simplify the code with KHASH_FOREACH macro
2025-06-23 17:07:28 +09:00
Yukihiro "Matz" Matsumoto
eb1820d75e
symbol.c: remove unused <mruby/khash.h> header
2025-06-23 17:07:28 +09:00
Yukihiro "Matz" Matsumoto
e30ec3da42
mruby-metaprog: use KHASH_FOREACH macro
2025-06-23 17:07:28 +09:00
Yukihiro "Matz" Matsumoto
bce8cee8f9
khash.h (KHASH_FOREACH): a new macro to iterate over khash table
2025-06-23 17:07:28 +09:00
Yukihiro "Matz" Matsumoto
d41d477e22
mruby-set: add type checking helper functions
...
Add two helper functions to improve code clarity and maintainability:
- set_check_type: Checks if a value is a Set and raises an error if not
- set_is_set: Checks if a value is a Set and returns a boolean result
Update all relevant methods to use these helper functions, reducing
code duplication and centralizing type checking logic.
2025-06-23 17:07:27 +09:00
Yukihiro "Matz" Matsumoto
deb5c47fc6
mruby-set: implement comparison methods in C for better performance
...
Reimplemented the following methods in C for improved efficiency:
- superset? and proper_superset? (>= and >)
- subset? and proper_subset? (<= and <)
- intersect? and disjoint?
- <=> comparison operator
2025-06-23 17:07:27 +09:00
Yukihiro "Matz" Matsumoto
60f06e7a0f
mruby-set: Add comprehensive method documentation
2025-06-23 17:07:27 +09:00
Yukihiro "Matz" Matsumoto
091e48159a
mruby-set: Use numbered parameters for block arguments
2025-06-23 17:07:27 +09:00
Yukihiro "Matz" Matsumoto
04b38c2c47
mruby-set: rename internal methods
...
Renaming all internal C methods from __set_* to a cleaner __* convention
(e.g., __set_merge is now __merge), and updating their call sites in the
Ruby code accordingly.
2025-06-23 17:07:26 +09:00
Yukihiro "Matz" Matsumoto
e096eeed1a
mruby-set: reimplement #initialize in Ruby again
...
And we have eliminated mrb_funcall* from set.c.
2025-06-23 17:07:26 +09:00
Yukihiro "Matz" Matsumoto
5e2a7568e2
mruby-set: move #replace to Ruby again
...
Since it does only clear() and merge(), there is little use of the C
implemented fast path. This change also reduce memory consumption.
2025-06-23 17:07:26 +09:00
Yukihiro "Matz" Matsumoto
100ba913f2
mruby-set: extensive refactor in set.c
...
We refactor out loop by set_khash_foreach() function, so that we don't
need to repeat for loop. it makes the code simpler. The code is written
by Atlassian Rovodev.
2025-06-23 17:07:26 +09:00
Yukihiro "Matz" Matsumoto
f210772465
mruby-set: optimize Set operations to use mrb_get_arg1()
...
Replace mrb_get_args() with more efficient mrb_get_arg1() for
single-argument functions. The code is written by Atlassian Rovodev.
2025-06-23 17:07:26 +09:00
Yukihiro "Matz" Matsumoto
c117674cfe
mruby-set: refactor Set#replace
...
The code is written by Atlassian Rovodev.
2025-06-23 17:07:25 +09:00
Yukihiro "Matz" Matsumoto
8538c79f3f
mruby-set: refactor Set#merge
...
The code is written by Atlassian Rovodev.
2025-06-23 17:07:25 +09:00
Yukihiro "Matz" Matsumoto
169654ad9b
mruby-set: refactor Set#subtract
...
The code is written by Atlassian Rovodev.
2025-06-23 17:07:25 +09:00
Yukihiro "Matz" Matsumoto
c188b9a1aa
mruby-set: refactor Set#difference
...
The code is written by Atlassian Rovodev.
2025-06-23 17:07:25 +09:00
Yukihiro "Matz" Matsumoto
10ea05d3aa
mruby-set: refactor Set#union (+, |)
...
The code is written by Atlassian Rovodev.
2025-06-23 17:07:24 +09:00
Yukihiro "Matz" Matsumoto
d9f0c5a3a4
mruby-set: refactor Set#xor (^)
...
According to the similar strategy as Set#intersection.
The code is mostly written by Atlassian Rovodev.
2025-06-23 17:07:24 +09:00
Yukihiro "Matz" Matsumoto
56a41b844e
mruby-set: refactor Set#intersection
...
Define generic operation method in Ruby, then prepare fast-path function
in C as a general structure. Some methods will follow this pattern.
The code is generated by Atlassian Rovodev.
2025-06-23 17:07:24 +09:00
Yukihiro "Matz" Matsumoto
4ae3068b2a
mruby-set: replace mrb_funcall_id() by set_to_a()
2025-06-23 17:07:24 +09:00
Yukihiro "Matz" Matsumoto
73a1eb03e8
mruby-set: remove mrb_funcall_id() from set_join()
2025-06-23 17:07:24 +09:00
Yukihiro "Matz" Matsumoto
abae5a5ff5
mruby-set: remove __equal_fallback that no longer used
2025-06-23 17:07:23 +09:00
Yukihiro "Matz" Matsumoto
a2339a7fde
mruby-set: refactor set_equal() function
...
Made not to use mrb_funcall() as well.
2025-06-23 17:07:23 +09:00
Yukihiro "Matz" Matsumoto
72b51c4e92
mruby-set: I prefer newline before else keyword
2025-06-23 17:07:23 +09:00
Yukihiro "Matz" Matsumoto
655981c6ed
mruby-set: remove unused object allocation
...
AI added this allocation to avoid memory leaks, but actually this extra
allocation does nothing useful. We see more room for AI improvement.
2025-06-23 17:07:23 +09:00
Yukihiro "Matz" Matsumoto
e4ed04ba8b
mruby-set (set_init): adjust a local variable declaration
2025-06-23 17:07:23 +09:00
Yukihiro "Matz" Matsumoto
52285161e7
mruby-set: remove methods added by AI hallucination
2025-06-23 17:07:22 +09:00
Yukihiro "Matz" Matsumoto
1238fb2808
mruby-set (flatten_merge): remove unnecessary assignment
2025-06-23 17:07:22 +09:00
Yukihiro "Matz" Matsumoto
f44a7bc5db
mruby-set: remove statistic measurement code
2025-06-23 17:07:22 +09:00
Yukihiro "Matz" Matsumoto
7a1732d438
mruby-set: make #initialize_copy private
2025-06-23 17:07:22 +09:00