Age | Commit message (Collapse) | Author |
|
https://github.com/ruby/psych/commit/b9dec9f811
|
|
In Ruby < 3.0, the superclass of StringIO was actually already `Data`,
but it doesn't have the expected shape. So, on these earlier versions it errors:
> NoMethodError: undefined method `members' for #<StringIO:0x00005641dd5f2880>
> vendor/bundle/ruby/2.6.0/gems/psych-5.2.5/lib/psych/visitors/yaml_tree.rb:170:in `visit_Data'
This test doesn't fail on 2.7, presumably because it can pull in a newer `stringio` version.
https://github.com/ruby/psych/commit/0f40f56268
|
|
https://github.com/ruby/psych/commit/dbf9e36583
|
|
https://github.com/ruby/psych/commit/336553b412
|
|
https://github.com/ruby/psych/commit/e954f96639
|
|
https://github.com/ruby/psych/commit/30a2a5ee94
|
|
Use feature testing to detect native Set,
and don't rely on `Set#to_h` which wasn't intended
as a public method.
https://github.com/ruby/psych/commit/d58cff11af
|
|
https://github.com/ruby/psych/commit/3573fb356e
|
|
https://github.com/ruby/psych/commit/9df5501fdc
|
|
This sets the ivars _before_ calling initialize, which feels wrong. But
Data doesn't give us any mechanism for setting the members other than 1)
initialize, or 2) drop down into the C API. Since initialize freezes
the object, we need to set the ivars before that. I think this is a
reasonable compromise—if users need better handling, they can implement
their own `encode_with` and `init_with`. But it will lead to unhappy
surprises for some users.
Alternatively, we could use the C API, similarly to Marshal. Psych _is_
already using the C API for path2class and build_exception. This would
be the least surprising behavior for users, I think.
|
|
https://github.com/ruby/psych/commit/788b844c83
|
|
This fixes the issue where regular expression would come back slightly
different after going through a YAML load/dump cycle. Because we're used
to having to escape forward slashes in regular expression literals
(because the literal is delimited by slashes), but the deserializer
takes the literal output from `Regexp#inspect` and feeds it as a string
into `Regexp.new`, which expects a string, not a Regexp literal, cycling
did not properly work before this commit.
I've also changed the code to be a bit more readable, I hope this
doesn't affect performance.
https://github.com/ruby/psych/commit/f4dd8dadad
|
|
https://github.com/ruby/psych/commit/bb63f91825
|
|
Since `Set` no longer is a regular object class holding a Hash
it needs to be specially handled.
https://github.com/ruby/psych/commit/c2d185d27c
|
|
Fix https://github.com/ruby/psych/pull/644
https://github.com/ruby/psych/commit/b1ade765ba
|
|
Followup: https://github.com/ruby/psych/pull/686
This single call shows up as 4% of some controller actions
in the lobsters benchmark.
Profile: https://share.firefox.dev/3EqKnhS
https://github.com/ruby/psych/commit/b77bfee092
|
|
https://github.com/ruby/psych/commit/2af9f6ac02
|
|
Fixes ruby/psych#689
https://github.com/ruby/psych/commit/ac887cdc76
|
|
https://github.com/ruby/psych/commit/2f46abf4e1
|
|
https://github.com/ruby/psych/commit/746e1ad24d
|
|
https://docs.ruby-lang.org/en/master/Psych.html#module-Psych-label-Exception+handling
https://github.com/ruby/psych/commit/c53c298222
|
|
https://github.com/ruby/psych/commit/7c81f7db53
|
|
The evaluation order of C arguments is unspecified.
`RSTRING_LEN(value)` would fail if the conversion to a String by
`StringValuePtr(value)` is not done yet.
Coverity Scan found this issue.
https://github.com/ruby/psych/commit/d1e6bf323a
|
|
https://github.com/ruby/psych/commit/b2aa0032c0
|
|
https://github.com/ruby/psych/commit/6ea07fdadd
|
|
https://github.com/ruby/psych/commit/6609955e68
|
|
https://github.com/ruby/psych/commit/b89064efa5
|
|
https://github.com/ruby/psych/commit/48e5af8454
|
|
https://github.com/ruby/psych/commit/288febbc87
|
|
https://github.com/ruby/psych/commit/d9e18aaab7
|
|
https://github.com/ruby/psych/commit/a0c353ec97
|
|
Save on allocating useless `MatchData` instances.
https://github.com/ruby/psych/commit/b2d9f16e58
|
|
A string similar to "0x____" should be treated as a string.
Currently it is processed as an Integer.
This alters the regex specified by http://yaml.org/type/int.html
to ensure at least one numerical symbol is present in the string
before converting to Integer.
https://github.com/ruby/psych/commit/81479b203e
|
|
https://github.com/ruby/psych/commit/a8b73bb80e
|
|
https://github.com/ruby/psych/commit/3b63a93dfc
|
|
https://github.com/ruby/psych/commit/9f5392d180
|
|
https://github.com/ruby/psych/commit/ce7946981d
|
|
When an exception is raised, it can leak memory in `head`. There are two
places that can leak memory:
1. `Check_Type(tuple, T_ARRAY)` can leak memory if `tuple` is not an
array.
2. `StringValue(name)` and `StringValue(value)` if they are not strings
and the call to `to_str` does not return a string.
This commit fixes these memory leaks by wrapping the code around a
rb_ensure so that the memory is freed in all cases.
The following code demonstrates the memory leak:
emitter = Psych::Emitter.new(StringIO.new)
nil_to_string_tags = [[nil, "tag:TALOS"]] + ([1] * 1000)
expected_array_tags = [1] * 1000
10.times do
1_000.times do
# Raises `no implicit conversion of nil into String`
emitter.start_document([], nil_to_string_tags, 0)
rescue TypeError
end
1_000.times do
# Raises `wrong argument type Integer (expected Array)`
emitter.start_document([], expected_array_tags, 0)
rescue TypeError
end
puts `ps -o rss= -p #{$$}`
end
Before:
47248
79728
111968
144224
176480
208896
241104
273280
305472
337664
After:
14832
15088
15344
15344
15360
15632
15632
15632
15648
15648
https://github.com/ruby/psych/commit/053af73818
|
|
https://github.com/ruby/psych/commit/74a6b4d226
|
|
https://github.com/ruby/psych/commit/e7d64c9848
|
|
Ref: https://bugs.ruby-lang.org/issues/20641
Even without the reference bug, `require 'date'` isn't cheap.
```ruby
require "benchmark/ips"
require "yaml"
require "date"
100.times do |i|
$LOAD_PATH.unshift("/tmp/does/not/exist/#{i}")
end
payload = 100.times.map { Date.today }.to_yaml
Benchmark.ips do |x|
x.report("100 dates") { YAML.unsafe_load(payload) }
end
```
Before:
```
$ ruby /tmp/bench-yaml.rb
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
Warming up --------------------------------------
100 dates 416.000 i/100ms
Calculating -------------------------------------
100 dates 4.309k (± 1.2%) i/s - 21.632k in 5.021003s
```
After:
```
$ ruby -Ilib /tmp/bench-yaml.rb
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
Warming up --------------------------------------
100 dates 601.000 i/100ms
Calculating -------------------------------------
100 dates 5.993k (± 1.8%) i/s - 30.050k in 5.016079s
```
|
|
|
|
for dumping
https://github.com/ruby/psych/commit/3d051d89aa
|
|
By providing a 'changelog_uri' in the metadata of the gemspec
a 'Changelog' link will be shown on https://rubygems.org/gems/psych
which makes it quick and easy for someone to check on the changes
introduced with a new version.
Details of this functionality can be found on https://guides.rubygems.org/specification-reference/
https://github.com/ruby/psych/commit/28ef10edcf
|
|
https://github.com/ruby/psych/commit/93c8fb443a
|
|
https://github.com/ruby/psych/commit/6905a2123c
|
|
https://github.com/ruby/psych/commit/b9e7b4a4a4
|
|
https://github.com/ruby/psych/commit/a9ab74d132
|
|
Object IDs became more expensive in Ruby 2.7. Using `Hash#compare_by_identity` let's us get the same effect, without needing to force all these objects to have object_ids assigned to them.
https://github.com/ruby/psych/commit/df69e4a12e
|
|
Use safe navigation operator with each_char to remove empty strings and improve readability.
https://github.com/ruby/psych/commit/5fe714b216
|