tsoding / ded

Dramatic EDitor
MIT License
579 stars 76 forks source link

Use an array instead of a switch in token_kind_name #63

Open RHL120 opened 1 year ago

RHL120 commented 1 year ago

This change removes 19 lines of code and gives the function a (negligible) speed improvement .

janw4ld commented 1 year ago

this removes the concrete link between each Token_kind value and the name that represents it, which makes the code less readable and less extensible. the data structure that would be an improvement is a map, but that's pretty overkill

RHL120 commented 1 year ago

this removes the concrete link between each Token_kind value and the name that represents it, which makes the code less readable and less extensible. the data structure that would be an improvement is a map, but that's pretty overkill

Yeah I guess there is a trade off here, I would chose the array method but the maintainer might disagree with me. Thanks for the review!

BillKek commented 1 year ago

Speed improvement makes by the compiler itself, IMHO. And UNREACHABLE feature lost.

RHL120 commented 1 year ago

Speed improvement makes by the compiler itself, IMHO. And UNREACHABLE feature lost.

I can put it back.