| Age | Commit message (Collapse) | Author |
|
Because location info (file name and line number) is kept in the backtrace,
it should not be kept in the result of `inspect` (and the exception object
itself), I think.
### Example
```ruby
# example.rb
begin
raise "err"
rescue => e
p e
end
```
#### Before this patch:
```
$ bin/mruby example.rb
example.rb:2: err (RuntimeError)
```
#### After this patch:
```
$ bin/mruby example.rb
err (RuntimeError)
```
|
|
#### Before this patch:
```ruby
Integer("1_ ") #=> 1
```
#### After this patch (same as Ruby):
```ruby
Integer("1_ ") #=> ArgumentError
```
|
|
#### Before this patch:
```ruby
Integer("_1") #=> 1
"_1".to_i #=> 1
```
#### After this patch (same as Ruby):
```ruby
Integer("_1") #=> ArgumentError
"_1".to_i #=> 0
```
|
|
Consecutive `_` is not allowed as a numeric expression:
1_2__3 #=> SyntaxError
Float("1_2__3") #=> ArgumentError
Integer("1_2__3") #=> ArgumentError
"1_2__3".to_i #=> 12
But `String#to_f` accept it, so I fixed the issue.
Before this patch:
"1_2__3".to_f #=> 123
After this patch:
"1_2__3".to_f #=> 12
|
|
#### Before this patch:
```
$ bin/mruby -e 'Float("1_a")'
-e:1: invalid string for float(a) (ArgumentError)
```
#### After this patch:
```
$ bin/mruby -e 'Float("1_a")'
-e:1: invalid string for float("1_a") (ArgumentError)
```
|
|
The bit width terminology is unified to `BIT` according to `MRB_INT_BIT`
and `CHAR_BIT`. Also the bit position terminology is unified to `BIT_POS`.
|
|
Previously, `mrb_int` was used as the type that represents the buffer size
on memory, but the sizes of `RString` and `RArray` exceed 6 words when
`MRB_INT64` is enabled on 32-bit CPU.
I don't think it is necessary to be able to represent the buffer size on
memory that exceeds the virtual address space. Therefore, for this purpose,
introduce `mrb_ssize` which doesn't exceed the sizes of `mrb_int` and
pointer.
I think all `mrb_int` used for this purpose should be changed to
`mrb_ssize`, but currently only the members of the structures (`RString`,
`mrb_shared_string`, `RArray` and `mrb_shared_array`) are changed.
|
|
- Keep `MRB_STR_ASCII` flag.
- Avoid a string object creation.
|
|
|
|
|
|
|
|
|
|
|
|
### Benchmark (with `MRB_UTF8_STRING`)
```
$ mruby -e '
COUNT = 150000
SIZE = 10000
strs = Array.new(COUNT) do
s = "a" * SIZE
s.size # set `MRB_STR_ASCII` flag
s
end
i = 0
t = Time.now
while i < COUNT
strs[i][-2..-1] = ""
i += 1
end
printf "%.2f sec\n", Time.now - t
'
1.10 sec # before
0.07 sec # after
```
|
|
### Benchmark (with `MRB_UTF8_STRING`)
```ruby
# benchmark.rb
COUNT = 300000
SIZE = 10000
s = "a" * SIZE
s.size # set `MRB_STR_ASCII` flag
i = 0
while i < COUNT
s[-1]
i += 1
end
```
#### Before this patch:
```
$ time mruby benchmark.rb
2.06 real 2.05 user 0.00 sys
```
#### After this patch:
```
$ time mruby benchmark.rb
0.05 real 0.04 user 0.00 sys
```
|
|
### Example (with `MRB_UTF8_STRING`)
```ruby
s = "\u3042"
p s.size
s.dump
p s.size
```
#### Before this patch:
```
1
3
```
#### After this patch:
```
1
1
```
|
|
|
|
shuujii/sHARED-string-is-not-required-when-sharing-POOL-string
SHARED string is not required when sharing POOL string
|
|
The heap string buffer of POOL string always exists, does not need to be
released, and read only, so it can be shared as NOFREE string.
|
|
Because it may not create `struct mrb_shared_string`.
|
|
|
|
|
|
This is an experimental changes in Ruby 2.7.
|
|
Also fix document about type of the first argument.
|
|
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for
all `enum mrb_vtype`).
|
|
* mrb_sym2name -> mrb_sym_name
* mrb_sym2name_len -> mrb_sym_name_len
* mrb_sym2str -> mrb_sym_str
|
|
Also fix document about type of the first argument.
|
|
|
|
|
|
1. `$/` and other Perl-ish global variables are not defined in ISO.
2. The current Ruby policy do not encourage those variables.
3. Those variables has global effect and can cause troubles.
|
|
Unlike CRuby, there's no way to process strings byte-wise by core
methods because there's no per string encoding in mruby, so that
we moved 3 byte-wise operation methods from `mruby-string-ext` gem.
|
|
|
|
Prioritize embedded string in the following functions:
- `str_new_static`
- `str_new`
- `mrb_str_new_capa`
- `mrb_str_pool`
The reasons are as follows:
- Consistency with `mrb_str_byte_subseq` and `str_replace`.
- Memory locality increases and may be slightly faster.
- No conversion cost to embedded string when modifying the string.
|
|
On 64-bit CPU, there is padding in `RBasic`, so reorder the fields and use
it as buffer of embedded string. This change allows 4 more bytes to be
embedded on 64-bit CPU.
However, an incompatibility will occur if `RString::as::ary` is accessed
directly because `RString` structure has changed.
|
|
|
|
Simplify get arguments
|
|
shuujii/rename-mrb_shared_string-len-to-mrb_shared_string-capa
Rename `mrb_shared_string::len` to `mrb_shared_string::capa`
|
|
Because this field is used as capacity of string buffer.
|
|
|
|
- `mrb_str_index_m()` and `mrb_str_rindex()`
Make `mrb_get_args()` called only once from called twice.
- `mrb_str_byteslice()`
Replace `goto` with `if ~ else`.
|
|
Refactor set/unset string type flags
|
|
Introduce `RSTR_SET_TYPE_FLAG` macro to set the specified string type flag and
clear the others.
|
|
Previously `String#rindex` returned the wrong index when given an
invalid UTF-8 string.
```terminal
% ruby26 -e 'str = "\xf0☀\xf1☁\xf2☂\xf3☃\xf0☀\xf1☁\xf2☂\xf3☃"; p str.rindex("☁")'
11
% ./mruby-head -e 'str = "\xf0☀\xf1☁\xf2☂\xf3☃\xf0☀\xf1☁\xf2☂\xf3☃"; p str.rindex("☁")'
nil
% ./mruby-patched -e 'str = "\xf0☀\xf1☁\xf2☂\xf3☃\xf0☀\xf1☁\xf2☂\xf3☃"; p str.rindex("☁")'
11
```
|
|
I think the string buffer of NOFREE string always exists and does not need
to be released, so it can be shared as another NOFREE string.
Also changed the `mrb_shared_string` field order so that eliminate padding if
`int` and `mrb_int` sizes are less than pointer size.
|
|
|
|
|
|
|
|
|
|
shuujii/mrb_str_modify_keep_ascii-can-embed-one-more-byte
`mrb_str_modify_keep_ascii` can embed one more byte
|
|
|