Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require utf-8 source files #511

Merged
merged 5 commits into from
Oct 1, 2023
Merged

Don't require utf-8 source files #511

merged 5 commits into from
Oct 1, 2023

Conversation

ehaas
Copy link
Collaborator

@ehaas ehaas commented Sep 28, 2023

This removes the requirement that source files always be UTF-8 encoded. Identifiers are still required to be UTF-8 encoded; and there is a todo item for char literals to match clang/gcc behavior when the source text of the literal is not UTF-8 encoded.

Some simple testing on my machine shows that skipping the up-front UTF-8 validation is significantly faster for large files - the 8.4 meg amalgamated sqlite3.c source parses in ~400ms on master; and ~340ms on this branch for me.

@ehaas
Copy link
Collaborator Author

ehaas commented Sep 29, 2023

@squeek502 when you get a chance can you try out this PR and see if it fixes the encoding issues you were seeing? You'll need a fairly recent build of the Zig compiler. It should also be somewhat faster than before since we're no longer scanning the whole file up front to validate UTF8-ness.

@squeek502
Copy link
Contributor

Haven't investigated fully yet, but preliminary results are good. This branch brings the win32-samples-rc-tests results to:

57 .rc files processed with discrepancies
different .res outputs:     0
unexpected compile errors:  57
missing compile errors:     0

428 .rc files processed without discrepancies
identical .res outputs:     403
expected compile errors:    25

up from

83 .rc files processed with discrepancies
different .res outputs:     0
unexpected compile errors:  83
missing compile errors:     0

402 .rc files processed without discrepancies
identical .res outputs:     377
expected compile errors:    25

@ehaas ehaas marked this pull request as ready for review October 1, 2023 06:52
Copy link
Owner

@Vexu Vexu left a comment

Choose a reason for hiding this comment

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

These are some really nice changes!

const slice = p.tokSlice(p.tok_i);
const view = std.unicode.Utf8View.init(slice) catch {
try p.errTok(.invalid_utf8, p.tok_i);
return error.FatalError;
Copy link
Owner

Choose a reason for hiding this comment

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

This looks like a place for future improvements.

@Vexu Vexu merged commit b8dd064 into Vexu:master Oct 1, 2023
3 checks passed
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.

3 participants