.Len() vs Variables

What is better practice?

const int32 WordLength = CurrentWord.Len();
if (WordLength >= 4 && WordLength <= 8 && IsIsogram(CurrentWord))
{
    ...
}

or

if (CurrentWord.Len() >= 4 && CurrentWord.Len() <= 8 && IsIsogram(CurrentWord))
{
    ...
}

Especially if this code runs in a HUGE loop

Having walked a bit further along the course, I realized that it is better to use a function than to create a new variable that will allocate 4 Bytes of memory each time.

Depending on the situation of course)

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms