Commit graph

116 commits

Author SHA1 Message Date
Ethiraric
65fcb6fde3 Move next_can_be_plain_scalar as free fn.
This is, for some reason, a huge pessimization. `rustc` fails to
optimize it as well as it did when it was part of `Scanner`.

This is however kinda needed if I want to avoid having this code
duplicated in every implementation of the input.
2024-07-14 17:01:44 +02:00
Ethiraric
693cc19042 Avoid too many lookaheads in scan_plain_scalar. 2024-07-14 17:00:10 +02:00
Ethiraric
93a35ab6f7 Move document indicator detection to Input. 2024-07-14 17:00:10 +02:00
Ethiraric
afa1b2319f Remove 1 line wrappers. 2024-07-14 17:00:08 +02:00
Ethiraric
f8b6d849d3 Performance improvement.
The refactoring added `next_is` which takes a `&str` as parameter, while
we only use it with strings of lengths 2 and 3. Replacing this by 2
dedicated methods (which can be added to the trait interface and only
specialized if needed) removes almost all the overhead that was added by
`Input`.
2024-07-14 16:59:10 +02:00
Ethiraric
d9bb7a1693 Add Input interface.
Hiding character fetching behind this interface allows us to create more
specific implementations when is appropriate. For instance, an instance
of `Input` can be created for a `&str`, allowing for borrowing and more
efficient peeking and traversing than if we were to fetch characters one
at a time and placing them into a temporary buffer.
2024-07-14 16:59:09 +02:00
Ethiraric
11cffc6df8 Fix issue with deeply indented block scalars.
Fixes #2
2024-07-14 16:57:26 +02:00
Ethiraric
750c992121 Add support for nested implicit flow mappings.
These are corner cases not tested by the `yaml-test-suite`.
Parsing for the reported input has been fixed, as well as other
similar-looking inputs which make use of nested implicit flow mappings
and implicit null keys and values.

Fixes #1.
2024-07-02 01:56:34 +02:00
Ethiraric
f8f6281e41 Add Marker::default and pub to new. 2024-06-13 22:17:54 +02:00
Ethiraric
c3d83fbfe1 Fix warnings. 2024-06-13 22:05:43 +02:00
Ethiraric
9ee2d113bc Fix error with comments after tags. 2024-04-16 12:03:42 +02:00
Ethiraric
cbba46fa72 Have ScanError::new take a String.
Internally, `ScanError` stores a `String`. Having `new` take a `&str`
misleadingly indicates that it stores a `&str`. This commit changes
`new` so that it takes a `String`, and adds a convenience method,
`new_str` that takes a `&str` and allocates a `String` for it.
2024-04-07 02:04:45 +02:00
Ethiraric
3b1dee5ef7 Remove deprecated method implementations of Error. 2024-04-07 02:01:26 +02:00
Ethiraric
bf2aaf8044 Add doc checks to before_commit. 2024-03-28 21:06:32 +01:00
John Vandenberg
6ec65e636f fix typos 2024-03-25 14:52:44 +01:00
Ethiraric
ccd7b6e718 Add missing_docs warning. 2024-03-20 16:00:30 +01:00
David Aguilar
a120d93e7d Enable the missing-errors-doc clippy checks 2024-03-19 15:26:16 +01:00
David Aguilar
9e505d552f Eliminate panics and enable the missing panics docs check 2024-03-19 15:26:16 +01:00
David Aguilar
a42f26b306 Enable the redundant-else clippy checks 2024-03-19 15:26:16 +01:00
David Aguilar
e36369d69c Enable the case-arms clippy checks 2024-03-19 15:26:16 +01:00
Jim Turner
03e3047937 Add byte a offset to the error message 2024-03-19 15:26:16 +01:00
Ethiraric
e7a4f30627 Replace VecDeque with ArrayDeque.
This removes all allocations in the `Scanner` code. The downside is that
the buffer is now stored in the `Scanner` structure, making it 48 bytes
larger. This however makes the code much more performant.
2024-02-13 23:10:32 +01:00
Ethiraric
603c3c546f Fix some clippy lints. 2024-02-13 23:10:17 +01:00
Ethiraric
e93947bcfe Minor improvements. 2024-01-31 22:02:53 +01:00
Ethiraric
4fee65f27a Improve scan_plain_scalar readability.
Take whitespace checking out of the innermost loop for performance.
2024-01-25 03:06:18 +01:00
Ethiraric
28893c4567 Avoid a trip to self.buffer.
`self.buffer` is a `VecDeque<char>`, meaning that characters are stored
on 4B. When reading as we used to do, this means that every 1 byte
character we read was turned into 4 bytes, which was turned into 1 byte
in `String::extend`.

Instead of going through `self.buffer`, use a local `String` to store
the characters before pushing them to `string`.
2024-01-24 23:02:02 +01:00
Ethiraric
2471c5793a Buffer block scalar lines.
Instead of doing a loop that goes:
  * fetch from input stream
  * push char into string

Make a loop that fetches characters while they're not a breakz and
_then_ extend the string. This avoids a bunch of reallocations.
2024-01-24 21:45:18 +01:00
Ethiraric
7a51c3dfca Split skip into more specific variants.
This function is a hotpath and sometimes removing the conditional jump
to detect line breaks saves a bunch of instructions.
2024-01-24 20:20:52 +01:00
Ethiraric
666965ef4f Doing this leads to worse performance. 2024-01-24 19:42:18 +01:00
Ethiraric
4153a98973 Pre-load chars in skip_block_scalar_indent. 2024-01-24 19:31:45 +01:00
Ethiraric
980d5b0335 Help the compiler inline read_break. 2024-01-24 17:14:52 +01:00
Ethiraric
bcdd725049 Remove debug prints code from release builds.
If building release mode, remove debug code. Now, the `debug_print!`
macro resolves to nothing in release build.

In debug build, don't check the environment for each print. This has a
huge overhead. The environment is only checked once and next checks are
made against a simple boolean value.
2024-01-24 02:22:02 +01:00
Ethiraric
06936742f2 Move char is_xxx fn to their own file. 2024-01-24 01:02:20 +01:00
Ethiraric
f2d0968a89 Fix null nodes with tags in flow constructs. 2024-01-23 00:19:04 +01:00
Ethiraric
4b37abf2b7 Fix tag scanning. 2024-01-23 00:19:04 +01:00
Ethiraric
84a7d2a0ab Fix indent in block scalars. 2024-01-23 00:19:04 +01:00
Ethiraric
3868b83756 Fix dquote indentation. 2024-01-23 00:19:04 +01:00
Ethiraric
36c4f8951e Fix dquote string escape sequences. 2024-01-23 00:19:04 +01:00
Ethiraric
71c54f318f Fix tests related to anchor/alias indentation.
I have no idea what I'm doing.
2024-01-23 00:19:04 +01:00
Ethiraric
ca7579a3c9 Fix flow adjacent value with complex key. 2024-01-23 00:19:04 +01:00
Ethiraric
ef799af5eb Fix use of dashes in flow contexts. 2024-01-23 00:19:04 +01:00
Ethiraric
c60099af9b Fix block scalar / eof interactions. 2024-01-23 00:19:04 +01:00
Ethiraric
9b653e607b Fix block scalars and document end interaction. 2024-01-23 00:19:04 +01:00
Ethiraric
7a3e3b05b4 Fixes towards spaces before comments. 2024-01-23 00:19:04 +01:00
Ethiraric
99d82be6a3 Fix possible misindent in block scalar. 2024-01-23 00:19:04 +01:00
Ethiraric
bff3c4ccaf Fix towards invalid trailing characters. 2024-01-23 00:19:04 +01:00
Ethiraric
032efff867 Split fetch_flow_scalar. 2024-01-23 00:19:04 +01:00
Ethiraric
81104ba833 Fix towards flow mapping and colons. 2024-01-23 00:19:04 +01:00
Ethiraric
4603e31a67 Finally grasped how SimpleKey works.
This is a huge commit that cannot easily be broken down as it contains
fixes for the next ignored test in the suite which, one fixed, broke
tests that used to pass and were only then fixed.

There is also a substantial amount of comments that were added,
especially around `SimpleKey`. Minor improvements around the code were
added and I did not bother making a separate commit for them.

Overall, that commit fixes 7 tests from the matrix that were related to
the handling of simple keys.
2024-01-23 00:19:04 +01:00
Ethiraric
795193483e Minor improvement to debug prints. 2024-01-23 00:19:04 +01:00