Skip to content

Parse null,true/false directly from the buffer, avoid copying#25492

Open
planetis-m wants to merge 1 commit intonim-lang:develfrom
planetis-m:patch-35
Open

Parse null,true/false directly from the buffer, avoid copying#25492
planetis-m wants to merge 1 commit intonim-lang:develfrom
planetis-m:patch-35

Conversation

@planetis-m
Copy link
Contributor

No description provided.

my.bufpos = pos
proc parseKeyword(my: var JsonParser): TokKind =
let pos = my.bufpos
case my.buf[pos]
Copy link
Contributor

@arnetheduck arnetheduck Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens when my.buf.len <= pos + len(match)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I suppose it reads the terminating character and works correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... or, more likely, [] raises a defect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way this parser is built and also looking at lexbase.nim, it makes the assumption that [] doesnt perform range checks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see 👍 there's an extra non-ident character injected always, it seems so although [] performs a range check it should not be violated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants