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

tokens shouldn't need to track rawkind, rawvalue, only prefixes #2

Open
bgentry opened this issue Jan 30, 2014 · 0 comments
Open

tokens shouldn't need to track rawkind, rawvalue, only prefixes #2

bgentry opened this issue Jan 30, 2014 · 0 comments

Comments

@bgentry
Copy link
Owner

bgentry commented Jan 30, 2014

Here's the current token struct:

type token struct {
    kind      tkType
    macroName string
    value     string
    rawkind   []byte
    rawvalue  []byte
}

The fields rawkind and rawvalue track the original bytes from the token's kind and value, as well as the prefixing spaces (including newlines).

Everything aside from the prefix is redundant w/ the fields like kind and value. This makes for some extra work when updating values or initializing tokens.

Instead, we could rename these fields to valuePrefix and kindPrefix, and keep only the prefixing spaces in them. That would slightly complicate this append in MarshalText() but it seems like it'd be a huge improvement overall.

It would also eliminate the need to do copying on byte slices as they wouldn't be getting modified anymore.

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

No branches or pull requests

1 participant