ded icon indicating copy to clipboard operation
ded copied to clipboard

Use an array instead of a switch in token_kind_name

Open RHL120 opened this issue 2 years ago • 4 comments

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

RHL120 avatar Feb 12 '23 11:02 RHL120

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

kasimeka avatar Feb 12 '23 12:02 kasimeka

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!

RHL120 avatar Feb 12 '23 12:02 RHL120

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

BillKek avatar Feb 12 '23 14:02 BillKek

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

I can put it back.

RHL120 avatar Feb 12 '23 14:02 RHL120