Skip to content

Conversation

@mingodad
Copy link

It's not necessary to recalculate the "strlen(word)" on every loop comparison when "word" doesn't change inside the loop.

It's not necessary to recalculate the "strlen(word)" on every loop comparison when "word" doesn't change inside the loop.
Here also the same code as in word2vec.c
Copy link

@ccreutzig ccreutzig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler knows that, too, and will move the strlen call out of the loop: https://gcc.godbolt.org/z/Pnso2q

Making the change explicit is not necessarily a bad idea; but then, I would suggest having const unsigned long long str_len=strlen(word); in a line of its own.

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

Successfully merging this pull request may close these issues.

2 participants