Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Quick question: At the top of the parser they define

  const char VERTEX_STR[] = "vertex ";
And a few lines in

  data += strlen(VERTEX_STR);
Would parsers optimize this out? Seems like an easy win to replace that with a "7" (or a constant or something), although I don't know how much of a win it would be.


I was trusting the compiler on this one, but after someone asked this question on Twitter, I doubled-checked: https://cppx.godbolt.org/z/fhTGcx

Sure enough, it compiles down to "add rax, 7"


I figured it would, but I didn't want to assume. Thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: