google-labs-jules[bot]
71e8dbcd97
Refactor str_succ_bang for in-place modification
...
This commit refactors the str_succ_bang function in mrbgems/mruby-string-ext/src/string.c to perform string succession in-place.
The previous implementation used an intermediate temporary string, which incurred memory and performance overhead.
This change aims to reduce memory usage and improve performance by modifying the string buffer directly, using mrb_str_resize and memmove when prepending characters is necessary (e.g., '9' -> '10').
Formatting changes (newlines before 'else') have also been applied as per user request.
2025-06-23 09:23:54 +00:00
Yukihiro "Matz" Matsumoto
4e711fe0ef
mruby-string-ext: add README.md
...
The document is written by Google Jules.
2025-06-10 11:23:50 +09:00
Yukihiro "Matz" Matsumoto
5c2c77c71c
mruby-string (str_succ_bang): fixed sample string; close #6500
...
To avoid spellcheck failure in pre-commit.
2025-04-01 11:00:25 +09:00
Yukihiro "Matz" Matsumoto
6174541d82
mruby-encoding: move String#b to mruby-string-ext gem
2025-01-18 13:23:55 +09:00
Yukihiro "Matz" Matsumoto
351cd5aa46
mruby-string-ext: remove some methods moved to mruby-encoding
...
- String#valid_encoding?
- String#force_encoding
2025-01-16 09:12:09 +09:00
Yukihiro "Matz" Matsumoto
3b1c5d7397
mruby-string-ext: remove duplicated definition of String#b
...
When we use `mruby-encoding` gem as well.
2025-01-16 09:08:14 +09:00
Yukihiro "Matz" Matsumoto
0c01bf7ff0
mruby-string-ext: String#codepoints to support binary encoding
2025-01-16 09:06:19 +09:00
Yukihiro "Matz" Matsumoto
8395ffb5f8
mruby-string-ext: String#ord to support binary encoding
2025-01-16 09:00:44 +09:00
Yukihiro "Matz" Matsumoto
e47b4ca704
mruby-string-ext: new method String#force_encoding
...
It takes a string instead of Encoding object for simplicity
2025-01-12 23:13:28 +09:00
Yukihiro "Matz" Matsumoto
d5fa9504ad
mruby-string-ext (str_b): String#b should copy the receiver
2025-01-12 23:13:28 +09:00
Yukihiro "Matz" Matsumoto
6c530b8f48
mruby-string-ext (str_append_as_bytes): reimplement in C
...
To handle strings as byte sequences.
2025-01-12 23:13:27 +09:00
Yukihiro "Matz" Matsumoto
04ab2be2f0
mruby-string-ext (str_ascii_only_p): simplify the flag update
2025-01-03 08:47:38 +09:00
Yukihiro "Matz" Matsumoto
5a7c944a52
mruby-string-ext (str_b): simplify the flag update
2025-01-03 08:46:04 +09:00
Yukihiro "Matz" Matsumoto
b0127f0cdd
mruby-string-ext (str_b): add a new method String#b
...
The method makes the receiver binary-mode, but in mruby, which is
virtually no meaning.
2025-01-02 18:45:50 +09:00
Yukihiro "Matz" Matsumoto
85df487e63
mruby-string-ext (append_as_bytes): new method introduced by CRuby 3.4
...
Since mruby does not have Encoding support, append_as_bytes works
exactly same as String#concat.
2025-01-01 16:05:00 +09:00
Yukihiro "Matz" Matsumoto
45078d9a49
mruby-string-ext: fixed typo (casecmp! -> casecmp?)
2024-07-17 02:25:49 +09:00
Yukihiro "Matz" Matsumoto
c32a94d878
mruby-string-ext: use presym for initialization
2024-06-14 01:43:03 +09:00
Yukihiro "Matz" Matsumoto
06480f7147
mruby-string-ext: move local variable declarations
2024-05-08 11:29:20 +09:00
Yukihiro "Matz" Matsumoto
6f0c34e04e
mruby-string-ext: implement String#ascii_only? method
2024-01-18 22:53:46 +09:00
Yukihiro "Matz" Matsumoto
57fd0edaa7
mruby.h: rename ASCII flag to SINGLE_BYTE
...
This flag means all the characters in the string can be represented by a
single byte, i.e., the string does not contain any multi-byte character.
Those characters are likely ASCII characters, but may be a part of broken
UTF-8 sequence, so the term 'ASCII' is not sufficient.
2024-01-18 22:50:39 +09:00
Yukihiro "Matz" Matsumoto
4f8fd23f7a
mruby-string-ext (str_uminus): remove wrong document
...
In mruby, deduplication of strings is not implemented (yet), so we have
to remove the description from `String#-@` document.
2024-01-13 23:00:13 +09:00
Yukihiro "Matz" Matsumoto
c53d9a33fc
mruby-string-ext (mrb_valid_enc_p): simplify the code
...
By using `mrb_utf8len` directly. If `len == 1` and `ch >= 0x80`, the
character should be an invalid character.
2024-01-13 22:48:16 +09:00
Yukihiro "Matz" Matsumoto
658d5a51ac
mruby-string-ext: add test for String#valid_encoding?
2023-12-07 11:34:10 +09:00
Yukihiro "Matz" Matsumoto
eabe2d96e2
mruby-string-ext: add String#valid_encoding? method
2023-12-07 10:58:20 +09:00
Yukihiro "Matz" Matsumoto
7d3679dfc8
mruby-string-ext: refactoring
...
- raise exception in utf8code
- str_codepoints() use mrb_utf8len_table directly
2023-09-27 18:11:19 +09:00
Yukihiro "Matz" Matsumoto
5705d884ce
mruby-string-ext (utf8code): change arguments to point at the end
2023-09-27 18:08:12 +09:00
Yukihiro "Matz" Matsumoto
15bb6a9f9b
mruby-string-ext: fix a typo; ref #6016
2023-09-23 11:44:15 +09:00
Yukihiro "Matz" Matsumoto
8a538c40c0
mruby-string-ext: implement core part of codepoints in C; close #6061
2023-09-23 11:36:20 +09:00
Yukihiro "Matz" Matsumoto
d4a03be96b
mruby-string-ext/string.c (str_casecmp): small refactoring
2023-07-12 09:14:45 +09:00
Yukihiro "Matz" Matsumoto
f1a3cfbd3b
add a space between if and (
2023-05-22 11:55:21 +09:00
Yukihiro "Matz" Matsumoto
e0194bba67
mruby-string-ext/string.c: remove mrb_ prefix from static functions
2023-04-25 14:25:15 +09:00
Yukihiro "Matz" Matsumoto
a21edf75ad
Use mrb_get_arg1() instead of mrb_get_args() for single argument
2023-02-21 16:33:15 +09:00
Yukihiro "Matz" Matsumoto
a2e2e83012
string.c: move String#bytesplice to the core
2023-01-28 16:43:40 +09:00
Yukihiro "Matz" Matsumoto
12e232c006
mruby-string-ext/string.rb: add test for String#bytesplice
2023-01-28 16:41:40 +09:00
Yukihiro "Matz" Matsumoto
52746479a3
mruby-string-ext/string.c: new method String#byteslice
2023-01-27 23:22:02 +09:00
John Bampton
efd0e52cfd
Remove # coding: utf-8 from Ruby file
...
The default script encoding is Encoding::UTF-8 after v2.0.
https://ruby-doc.org/core-2.1.2/Encoding.html#class-Encoding-label-Script+encoding
2022-12-29 10:15:48 +10:00
Yukihiro "Matz" Matsumoto
48e5ca4802
include/value.h (mrb_float_p): define always
...
even when `MRB_NO_FLOAT` is set. In that case, it is FALSE always.
2022-12-24 19:05:41 +09:00
Yukihiro "Matz" Matsumoto
14f8cf040e
mruby-string-ext: add unary +/- for strings to freeze/unfreeze
2022-12-24 10:42:28 +09:00
Yukihiro "Matz" Matsumoto
9c5dc42e59
small cosmetic changes.
...
I prefer `i++` style unless absolutely necessary.
This commit is an addition to 41e4148.
2022-11-19 17:11:56 +09:00
John Bampton
ea8964ef35
ruby: standardize whitespace
2022-10-31 16:25:56 +10:00
John Bampton
44db4f18d3
Remove # coding: utf-8 from Ruby files
...
The default script encoding is Encoding::UTF-8 after v2.0.
https://ruby-doc.org/core-2.1.2/Encoding.html#class-Encoding-label-Script+encoding
2022-10-27 04:43:13 +10:00
Yukihiro "Matz" Matsumoto
11504318b8
string-ext/string.rb: String#prepend to take multiple arguments.
2022-09-20 18:31:04 +09:00
Yukihiro "Matz" Matsumoto
4cba1b49c0
string-ext/string.c: String#concat to take multiple arguments.
2022-09-20 18:26:23 +09:00
John Bampton
2990aaa343
pre-commit autoupdate, fix spelling, update codespell.txt
...
https://pre-commit.com/#pre-commit-autoupdate
2022-09-18 00:22:55 +10:00
Yukihiro "Matz" Matsumoto
d72d26afcb
mruby-string-ext/string.c: use the reference from mrb structure.
2022-09-12 10:27:31 +09:00
Yukihiro "Matz" Matsumoto
d55a152b3d
mruby-string-ext/string.c (utf8code): max length of UTF-8 is 4 bytes.
...
It used to be 6 bytes in RFC2279 but overridden by new RFC3629.
2022-05-29 22:19:00 +09:00
Yukihiro "Matz" Matsumoto
82b87be4df
string.c (mrb_utf8len): retry 7cdef2b0.
...
C++ requires `extern` declaration before variable definition.
2022-05-29 22:18:59 +09:00
Yukihiro "Matz" Matsumoto
82f0ba14a9
Revert "string.c: share UTF-8 length table with mruby-string-ext."
...
This reverts commit 7cdef2b03e .
This sharing does not with C++ compilers.
2022-05-25 16:07:52 +09:00
Yukihiro "Matz" Matsumoto
7cdef2b03e
string.c: share UTF-8 length table with mruby-string-ext.
2022-05-25 11:25:43 +09:00
Yukihiro "Matz" Matsumoto
be0b5f8cee
mruby-string-ext/string.c: reduce UTF-8 table size.
2022-05-25 11:22:28 +09:00