Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Which is faster?

Name: Anonymous 2011-10-10 23:42

++x or x+1?

Name: Anonymous 2011-10-10 23:47

they aren't equivalent. did you mean x = x+1 ?

Name: Anonymous 2011-10-10 23:54

hare>tortoise

Name: Anonymous 2011-10-11 1:13

x = x + 1
or
x += 1

Name: Anonymous 2011-10-11 1:15

If you use a crappy scripting language like Python or Ruby, ++x would be faster than x = x+1.

Name: Anonymous 2011-10-11 1:16

>>5
Also, in early days of C/C++, ++x was faster, that is why they invented a special operator.

Name: Anonymous 2011-10-11 1:34

>>6 1
Also, >>1 , don't you have anything better to do than increment a variable by one and then ask us how you can do it quicker?

Name: Anonymous 2011-10-11 3:43

It depends on the context; sometimes, a local variable can be optimized into a register. In that case, x+1 or x+=1 would result in an inc instruction, resulting in equivalent speed.

Name: Anonymous 2011-10-11 8:16

>>5
Ruby can't into ++ --

Name: Anonymous 2011-10-11 8:26

Obviously ++x because the addition is performed before

Name: Anonymous 2011-10-14 19:02

HOLY FUCK SHIT NIGGERBITCH! SUCK MY BIGASS DICK! I GOT DUBS AND YOU DIDN'T! CHECK 'EM YOU PUSSY ASS BITCH! LOOK AT YOU AND YOUR TINY DICK FART SINGLES! HAHA FUCK YOU TOO!

Don't change these.
Name: Email:
Entire Thread Thread List