{"action":"created","issue":{"url":"https://api.github.com/repos/pervognsen/bitwise/issues/9","repository_url":"https://api.github.com/repos/pervognsen/bitwise","labels_url":"https://api.github.com/repos/pervognsen/bitwise/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/pervognsen/bitwise/issues/9/comments","events_url":"https://api.github.com/repos/pervognsen/bitwise/issues/9/events","html_url":"https://github.com/pervognsen/bitwise/issues/9","id":305259976,"number":9,"title":"void next_token() with switch instead of if ?","user":{"login":"thee-engineer","id":17101435,"avatar_url":"https://avatars1.githubusercontent.com/u/17101435?v=4","gravatar_id":"","url":"https://api.github.com/users/thee-engineer","html_url":"https://github.com/thee-engineer","followers_url":"https://api.github.com/users/thee-engineer/followers","following_url":"https://api.github.com/users/thee-engineer/following{/other_user}","gists_url":"https://api.github.com/users/thee-engineer/gists{/gist_id}","starred_url":"https://api.github.com/users/thee-engineer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thee-engineer/subscriptions","organizations_url":"https://api.github.com/users/thee-engineer/orgs","repos_url":"https://api.github.com/users/thee-engineer/repos","events_url":"https://api.github.com/users/thee-engineer/events{/privacy}","received_events_url":"https://api.github.com/users/thee-engineer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-03-14T17:36:32Z","updated_at":"2018-03-15T06:07:42Z","closed_at":null,"author_association":"NONE","body":"Why does the `next_token()` function use such a huge switch case when it could be just a few if statements? Just curious if this is just a personal preference of @pervognsen or something else.\r\n\r\n```c\r\n// This is how I would see this done.\r\nvoid next_token() {\r\n    if (*stream >= '0' && *stream <= '9') {\r\n        uint64_t val = 0;\r\n        while (isdigit(*stream)) {\r\n            val *= 10;\r\n            val += *stream++ - '0';\r\n        }\r\n        token.kind = TOKEN_INT;\r\n        token.val = val;\r\n    } else if ((*stream >= 'a' && *stream <= 'z') || (*stream >= 'A' && *stream <= 'Z') || *stream == '_') {\r\n        const char *start = stream++;\r\n        while (isalnum(*stream) || *stream == '_') {\r\n            stream++;\r\n        }\r\n        token.kind = TOKEN_NAME;\r\n        token.start = start;\r\n        token.end = stream;\r\n    } else {\r\n        token.kind = *stream++;\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/pervognsen/bitwise/issues/comments/373270806","html_url":"https://github.com/pervognsen/bitwise/issues/9#issuecomment-373270806","issue_url":"https://api.github.com/repos/pervognsen/bitwise/issues/9","id":373270806,"user":{"login":"pervognsen","id":123173,"avatar_url":"https://avatars0.githubusercontent.com/u/123173?v=4","gravatar_id":"","url":"https://api.github.com/users/pervognsen","html_url":"https://github.com/pervognsen","followers_url":"https://api.github.com/users/pervognsen/followers","following_url":"https://api.github.com/users/pervognsen/following{/other_user}","gists_url":"https://api.github.com/users/pervognsen/gists{/gist_id}","starred_url":"https://api.github.com/users/pervognsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pervognsen/subscriptions","organizations_url":"https://api.github.com/users/pervognsen/orgs","repos_url":"https://api.github.com/users/pervognsen/repos","events_url":"https://api.github.com/users/pervognsen/events{/privacy}","received_events_url":"https://api.github.com/users/pervognsen/received_events","type":"User","site_admin":false},"created_at":"2018-03-15T06:07:42Z","updated_at":"2018-03-15T06:07:42Z","author_association":"OWNER","body":"The lexer will be used as part of a lexer+parser standalone library where it needs to be as fast as possible. Also, discussions/bikeshedding like this are not appropriate for pull requests."}}
{"actor":{"display_login":"pervognsen"}}