?
-
which is faster where x and y are small numbers that don't take too long
to count.
if (string.length() >= x && string.length() < y) {
...
}
or
int stringLength = string.length();
if (stringLength >= x && stringLength < y) {
...
}
and how many cpu 'cycles' does it take to initialize a variable so that
it can be determined which of the two methods above should be used
depending on the values of x and y.
i mean if x is 0 and y is 9, perhaps method 1 is recommended but if x is
0 and y is some big number, then it is better off to use method 2.
to count.
if (string.length() >= x && string.length() < y) {
...
}
or
int stringLength = string.length();
if (stringLength >= x && stringLength < y) {
...
}
and how many cpu 'cycles' does it take to initialize a variable so that
it can be determined which of the two methods above should be used
depending on the values of x and y.
i mean if x is 0 and y is 9, perhaps method 1 is recommended but if x is
0 and y is some big number, then it is better off to use method 2.