| Age | Commit message (Collapse) | Author |
|
|
|
https://github.com/ruby/prism/commit/230c8b8a48
|
|
Calculating code unit offsets for a source can be very expensive,
especially when the source is large. This commit introduces a new
class that wraps the source and desired encoding into a cache that
reuses pre-computed offsets. It performs quite a bit better.
There are still some problems with this approach, namely character
boundaries and the fact that the cache is unbounded, but both of
these may be addressed in subsequent commits.
https://github.com/ruby/prism/commit/2e3e1a4d4d
|
|
https://github.com/ruby/prism/commit/343197e4ff
|
|
https://github.com/ruby/prism/commit/25a4cf6794
Co-authored-by: Kevin Newton <kddnewton@users.noreply.github.com>
|
|
https://github.com/ruby/prism/commit/9c68c01bcd
|
|
This PR tweaks inspect representation of `Prism::Location`.
## Before
During debugging, the meaning of `@location=https://github.com/ruby/prism/commit/21474836481` was unclear:
```console
$ ruby -Ilib -rprism -e 'p Prism.lex("puts :hi").value.map(&:first)[1]'
#<Prism::Token:0x000000010cd74e40 @source=#<Prism::ASCIISource:0x000000010cb5f808 @source="puts :hi", @start_line=1, @offsets=[0]>,
@type=:SYMBOL_BEGIN, @value=":", @location=https://github.com/ruby/prism/commit/21474836481>
```
## After
This PR clarifies the contents of the location object, aligning with what I think user expects:
```console
$ ruby -Ilib -rprism -e 'p Prism.lex("puts :hi").value.map(&:first)[1]'
#<Prism::Token:0x000000010e174d50 @source=#<Prism::ASCIISource:0x000000010df5efe8 @source="puts :hi", @start_line=1, @offsets=[0]>,
@type=:SYMBOL_BEGIN, @value=":", @location=#<Prism::Location @start_offset=5 @length=1 start_line=1>>
```
Although it is uncertain whether Prism will accept this change in the inspect representation, it is submitted here as a suggestion.
https://github.com/ruby/prism/commit/e7421ce1c5
|
|
https://github.com/ruby/prism/commit/86cf82794a
|
|
https://github.com/ruby/prism/commit/4cc0eda4ca
|
|
https://github.com/ruby/prism/commit/fb7e1ebb7f
|
|
Having the @newline instance variable in every node adds up, and
since it is so rarely used, we only want to add it when necessary.
Moving this into an autoloaded file and moving the instance variable
out of the default initializers reduces allocated memory because the
nodes are now smaller and some fit into the compact list. On my
machine, I'm seeing about an 8% drop.
https://github.com/ruby/prism/commit/eea92c07d2
|
|
https://github.com/ruby/prism/commit/a298db68e3
|
|
https://github.com/ruby/prism/commit/40993166a8
|
|
https://github.com/ruby/prism/commit/cb4a8ab772
|
|
https://github.com/ruby/prism/commit/9b61f6fdb3
|
|
https://github.com/ruby/prism/commit/17194e096d
|
|
https://github.com/ruby/prism/commit/5dd57f4b84
|
|
https://github.com/ruby/prism/commit/1a8a0063dc
|
|
https://github.com/ruby/prism/commit/a735c2262f
|
|
https://github.com/ruby/prism/commit/5b2970e75b
|
|
For example, use `.fetch` or `.dig` instead of `[]`, and use `===` instead of `is_a?` for checking types of objects.
https://github.com/ruby/prism/commit/548b54915f
|
|
https://github.com/ruby/prism/commit/813e20d449
|
|
https://github.com/ruby/prism/commit/7905bdbf83
|
|
https://github.com/ruby/prism/commit/467e1cc2c4
|
|
https://github.com/ruby/prism/commit/9f00fe7510
|
|
https://github.com/ruby/prism/commit/5fda7a0760
|
|
https://github.com/ruby/prism/commit/0209d093ec
|
|
https://github.com/ruby/prism/commit/c6561becf0
|
|
Also make them lazy to allocate the array, and also expose ParseResult#encoding.
https://github.com/ruby/prism/commit/08ec7683ae
|
|
* Before it could result in NoMethodError if multiple threads were
calling location methods: https://gist.github.com/eregon/b78b7f266d7ee0a278a389cfd1782232
https://github.com/ruby/prism/commit/ff762dcccd
|
|
When creating the Ruby AST, we were previously allocating Location
objects for every node and every inner location. Instead, this
commit changes it to pack both the start offset and length into a
single u64 and pass that into the nodes. Then, when the locations
are requested via a reader method, we lazily allocate the Location
objects.
https://github.com/ruby/prism/commit/de203dca83
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
|
|
* Faster that way:
$ ruby -Ilib -rprism -rbenchmark/ips -e 'Benchmark.ips { |x| x.report("parse") { Prism.parse("1 + 2") } }'
195.722k (± 0.5%) i/s
rb_iv_set():
179.609k (± 0.5%) i/s
rb_funcall():
190.030k (± 0.3%) i/s
before this PR:
183.319k (± 0.4%) i/s
|
|
* As the user should not set these.
* Use #instance_variable_set/rb_iv_set() instead internally.
https://github.com/ruby/prism/commit/cace09fb8c
|
|
* Fixes https://github.com/ruby/prism/issues/2380
https://github.com/ruby/prism/commit/4eaaa90114
|
|
LSPs need this because the protocol dictates that you return code
units for offsets. None of our existing APIs provided that
information, and since we hid the source it's not nearly as useful
for them. Now they can pass an encoding directly to:
* Location#start_code_units_offset
* Location#end_code_units_offset
* Location#start_code_units_column
* Location#end_code_units_column
https://github.com/ruby/prism/commit/4757a2cc06
Co-Authored-By: Vinicius Stock <vinicius.stock@shopify.com>
|
|
https://github.com/ruby/prism/commit/1a15b70a8e
|
|
Split up the diagnostic levels so that error and warning levels
aren't mixed. Also fix up deconstruct_keys implementation.
https://github.com/ruby/prism/commit/bd3eeb308d
Co-authored-by: Benoit Daloze <eregontp@gmail.com>
|
|
* So it's clear it is a Symbol.
Before:
... @level=warning_verbose_true>
After:
... @level=:warning_verbose_true>
https://github.com/ruby/prism/commit/84503643b9
|
|
* Fixes https://github.com/ruby/prism/issues/2082
https://github.com/ruby/prism/commit/7a74576357
|
|
https://github.com/ruby/prism/commit/3e36d5eabc
|
|
https://github.com/ruby/prism/commit/42b60b6e95
|
|
(https://github.com/ruby/prism/pull/1809)
https://github.com/ruby/prism/commit/d493ccd093
|
|
We were previously holding a type field on Comment to tell what
kind of comment it was. Instead, let's just use actual classes for
this.
https://github.com/ruby/prism/commit/e76830ca6e
|
|
https://github.com/ruby/prism/commit/13fa262669
|
|
https://github.com/ruby/prism/commit/33cc75a4b7
|
|
https://github.com/ruby/prism/commit/ca9a660f52
|
|
https://github.com/ruby/prism/commit/085da4feb9
|
|
https://github.com/ruby/prism/commit/6d8358c083
|
|
https://github.com/ruby/prism/commit/c7ef25a79a
|
|
https://github.com/ruby/prism/commit/8eaa199a28
|