README.md in preval-0.2.0 vs README.md in preval-0.3.0
- old
+ new
@@ -26,14 +26,21 @@
If you're using the `bootsnap` gem, `preval` will automatically hook into its compilation step. Otherwise, you'll need to manually call `Preval.process(source)` with your own iseq loader (you can check out [yomikomu](https://github.com/ko1/yomikomu) for an example).
Each optimization is generally named for the function it performs, and can be enabled through the `enable!` method on the visitor class. If you do not explicitly call `enable!` on any optimizations, nothing will change with your source.
-* `Preval::Visitors::Arithmetic`
- * replaces constant expressions with their evaluation (e.g., `5 + 2` becomes `7`)
- * replaces certain arithmetic identities with their evaluation (e.g., `a * 1` becomes `a`)
-* `Preval::Visitors::Loops`
- * replaces `while true ... end` loops with `loop do ... end` loops
+* `Preval::Visitors::Arithmetic` replaces:
+ * constant expressions with their evaluation (e.g., `5 + 2` becomes `7`)
+ * arithmetic identities with their evaluation (e.g., `a * 1` becomes `a`)
+* `Preval::Visitors::Micro` replaces:
+ * `def foo; @foo; end` with `attr_reader :foo`
+ * `.gsub('...', '...')` with `.tr('...', '...')` if the arguments are strings and are both of length 1
+ * `.map { ... }.flatten(1)` with `.flat_map { ... }`
+ * `.reverse.each` with `.reverse_each`
+ * `.shuffle.first` with `.sample`
+* `Preval::Visitors::Loops` replaces:
+ * `for ... in ... end` loops with `... each do ... end` loops
+ * `while true ... end` loops with `loop do ... end` loops
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.