Commit Graph

13 Commits

Author SHA1 Message Date
Folkert
ef39bad7c6
auto clippy fixes 2023-07-10 18:27:08 +02:00
Gabriel Dertoni
7d0027f428
refactor: remove needles string allocation in pretty printer
Many times, in order to create a `ven_pretty::Doc` containing a text
node, the pattern `alloc.text(format!(...))` would be used. This code
then creates a fresh string that is then used in the `Doc`. However,
many times only a small string is necessary and so the allocation could
be optimized. The `ven_pretty` crate supports this through a `SmallString`
type. Allocating a fresh string with `format!` also moves control away
from the `DocAllocator` which isn't ideal, since it could also handle
the string allocations. So, instead of creating a fresh string, one can
simply call `alloc.as_string(format_args!(...))` and delegate the
allocation to the `DocAllocator` without any loss in expressivity. So,
in order to encorage this pattern, this commit also introduces the
`text!` macro.

In order to find all instances of the code pattern, the following
tree-sitter query was used:

```scm
(call_expression
    function: (field_expression
        field: (field_identifier) @field.name
               (#eq? @field.name "text"))
    arguments: (arguments
        (macro_invocation
            macro: (identifier) @macro.name
            (#eq? @macro.name "format")))) @reference.call
```
2023-05-03 21:28:36 -03:00
Folkert
4cd8f0a056 clippy --fix fixes 2023-04-21 12:05:51 +02:00
Anton-4
f55dbcacd1
fix pretty crate README link
Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
2023-03-27 14:04:34 +02:00
Brendan Hansknecht
72c36129a4
switch to iterators with some cloning to enable reserving HashSet size and avoiding the cost of rehashing 2023-03-22 13:41:40 -07:00
Brendan Hansknecht
9bfe2af259
switch away from drain and instead use into_iter 2023-03-22 13:41:40 -07:00
Brendan Hansknecht
3ef6d9846c
switch morphic to better hashing algorithms 2023-03-22 13:41:40 -07:00
Brendan Hansknecht
5e34621613
run cargo upgrade to update compatible version numbers 2023-03-07 12:39:43 -08:00
Anton-4
a97c53d7ca
1.65 changes and clippy fixes 2023-01-17 18:09:16 +01:00
Folkert
2c23a106f2
make inkwell a workspace dependency 2022-11-13 15:00:48 +01:00
Folkert
66a1ba00eb
1.65 clippy fixes 2022-11-03 16:20:37 +01:00
Richard Feldman
97e2900bf5
s/rtfeldman/roc-lang/g in links to GitHub repos 2022-08-12 15:24:09 -04:00
Anton-4
eee85fa45d
moved all crates into seperate folder + related path fixes 2022-07-01 17:37:43 +02:00