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

Pages: 1-4041-

Danger, Jason Robinson

Name: Anonymous 2009-10-31 19:49


for(int i = 0; i != 10; i++)
for(int i = 0; i < 10; i++)
for(int i = 0; i != 10; ++i)
for(int i = 0; i < 10; ++i)


From the options above, number 3's the best, isn't it?

Name: Anonymous 2009-10-31 19:53

The answer is, foreach.

Name: Anonymous 2009-10-31 20:03

for(int i = 0; 10 - i; ++i)
you heard me

Name: Anonymous 2009-10-31 20:10

2 is best.

Name: Anonymous 2009-10-31 20:12

>>1

The only difference between the adjacent pairs is jl gets replaced with jne

Name: Anonymous 2009-10-31 20:17

>>4
this man is correct

Name: Anonymous 2009-10-31 20:20

Hand-assembled with minor optimizations:


1_and_3:
        xor eax, eax
.loop:  inc eax
        cmp eax, 10
        jz .done
        ; Loop body
        jmp .loop
.done:

2_and_4:
        xor eax, eax
.loop:  inc eax
        cmp eax, 10
        jnl .done
        ; Loop body
        jmp .loop
.done: 

>>3:
        xor eax, eax
.loop:  inc eax
        mov ecx, eax
        sub ecx, 10
        jz .done
        ; Loop body
        jmp .loop
.done:


Though, with gcc -O2 they assemble to exactly the same thing.

Name: Anonymous 2009-10-31 20:36

You left one out.
for(int i = 0; i ^ 10; ++i)

Name: Anonymous 2009-10-31 20:48

>>8
He also missed out simple subtraction
for(int i = 0; i - 10; i++)

Name: Anonymous 2009-10-31 20:49

>>9
whoops, >>3 beat me to it >:|
I really should have read the thread first

Name: Anonymous 2009-10-31 21:40


          mov cx, 10
.forloop:
 
          loop .forloop

Name: Anonymous 2009-10-31 21:44

>>12
Get out of here, CISC boy.

Name: Anonymous 2009-10-31 21:44

>>11
Not programming related.

Name: Anonymous 2009-10-31 21:51

Please refrain from posting non-programming related material.

Thank you.

Name: Anonymous 2009-10-31 21:53

>>11
back to /r9k/ and stop infesting all the textboards with your whiny emo faggotry

Name: Anonymous 2009-10-31 23:30

MIPS doesn't have "branch on less than", only "branch if equal/not equal", so i != 10 would be better in that case.

Name: Anonymous 2009-11-01 12:37

>>17
These are the sorts of things the compiler is really good at figuring out on its on. They all amount to the same; just pick one and let the compiler do its job.

Name: Anonymous 2009-11-01 12:45

>>18
I will, along with my job

Name: Anonymous 2009-11-01 12:58

>>19
I'm afraid we're going to have to let you go

Name: Anonymous 2009-11-01 13:40

>>20
I will, along with my job

Name: Anonymous 2009-11-01 13:53

If possible you should loop downwards to zero, it's usually more efficient that way.

But to answer op, for such a small thing it's best to just unroll it:


i = 0;
(loop body)
i = 1;
(loop body)
i = 2;
(loop body)
i = 3;
(loop body)
i = 4;
(loop body)
i = 5;
(loop body)
i = 6;
(loop body)
i = 7;
(loop body)
i = 8;
(loop body)
i = 9;
(loop body)

Name: Anonymous 2009-11-01 14:01

>>22
Perform some human deadcode elimination and you get:
i = 9;

Name: Anonymous 2009-11-01 14:07


(dotimes (i 10))

Name: Anonymous 2009-11-01 14:21

>>22
Another thing the compiler can do for you. Christ people, stop fucking up your code, you're not helping.

Name: Anonymous 2009-11-01 14:22

(loop for i below 10)

Name: Anonymous 2009-11-01 14:24

>>25
Code isn't meant to be read, it is meant to execute.  I optimize everything in my code; I've had compilers fuck up my programs too many times.  I rewrote the Unix cat program so it was 7 ns faster (although this is a constant increase, because it was outside the parsing loop).

Name: Anonymous 2009-11-01 14:25


10.times{||i| puts i}

Name: Anonymous 2009-11-01 14:44

>>27
Enjoy being a human compiler.

Name: Anonymous 2009-11-01 16:12

#3 is recommended in C++ due to various Stroustrup faggotrees and BEST PRACTICE USS ENTERPRISE SOLUTIONS.
Nonretarded people will naturally prefer #2 (faggot) style.

Name: Anonymous 2009-11-01 20:42

>>27
obvious troll

Name: Name 2009-11-02 2:16

>>32
If it's so obvious, you don't need to tell us.

Name: Anonymous 2009-11-02 4:15

>>18
These are the sorts of things the compiler is really good at figuring out on its on. They all amount to the same; just pick one and let the compiler do its job.

For MIPS, gcc is terrible.

Name: Anonymous 2009-11-02 5:56

>>34
I hear the Intel compiler is really good at this stuff, why don't you just use that?

Name: Anonymous 2009-11-02 7:07

>>35
Why, INTEL

Name: Anonymous 2013-08-31 23:28



         ト、.,__        /7'iヽ.   八雲 紫  十七歳(自称)
        |:::::! `ヽ、__,,....,,___!::::! l:::|
        ';::::l‐ ''´|::|     /:::/-、|/     ┬ l二l ノ ノ ̄i_,
      / \'、   V   // / `ヽ.   土 l二l イ -‐ァ
     /  、__r-ヽ>' ̄`r‐'"ヽ!-'、、,__   ':,    ノ !_, | _メ、__
     ! r''「>'-‐'"´ ̄ ̄ `ヽ、7_ゝ-、ノ , .i
    r'Y´ / _/l_ ;    ; __!_ `ヽ、/ー、k_    __l_____,!__ -‐ァ  --'--  ノ-┼‐
   rく/  ,' ´/ _」_,ハ   ,ハ_」__` ',  ヽ/ _」_    !  /  --┼‐‐ __'三'__   -┼‐
   「´7   i  ァ'i´ '`!` ',  /' i´ 'ハ`i !  Y、___〉  _,>く..__  、ノ  | 口 」 ____|____
   `イ   ノレ,ハ. '、_,r!  レ'  !,__り.ノ`ハ ハ,.イ                       (自称)
    ノ  )へ/ !"´     .    `"7ノレ' i  `ヽ.
   ´⌒レ〉 ! ヘ.     ._ _,.    ,イ  ',.  '、   `':,
     ,./ ノ   ,!` :.、,       ,.イ /i,. -'‐'"`i `ヽ、  ':,
    ノ,' 〈  r'__,,.イ i`''= '"i. ト、/     i〉ヽ, !く{  i
  ,:'  !   !ヽ(ヘ!:::::'、`ヽ.__,. イ ./:::i    / く」ヽ  i
 /  ノ Y´:::::くンゝ:::::':、/ムヽ/:::;「ト、,____,ハト, レ'  i ハ
 !  〈  i、:;_::::/V':;::::::::Yl+lY::::::/:::!:ヽ、___i_ン7    ノ!〈 i
 ',  .) ハ:::::'':i:::::::::>'::ヽ+l+ン'::/!:::::::::::::!。i   ,:'´ !/_/
  )' (   ';:::::::ヽ;:::::\::::::Y/:/:::::!::::::::::::::::::! / }>!ヘ_」
 くンく{ ヽ. .';::::::::::i`::::::::ヽ:::!':::::::::::::!::::::::::::::::,' .,'  ノ i
    〉 !/i:::::::/::::::::::::::::Yo::::::::::::';:::::::::::::::i iヽ. 〈/
     (l |::::;:'`'':::::::::::::::l;o:::::::::::::ゝ、:;___ノ ,'  '(
       ,ァ'::::::::::::::::::::::;':::::::::::::::::::::::::!/`'(
    _,,..;:'く::::::::::::::::::::::/i::::::::::::::::::::::::::;ゝ,
 r‐''"/ /ヽ、:;______/TL__________;;::イ .ハ
 |::::,:'  ,'    i   !    i   ',   ':,
 |:,'   /     |    ',    :    ':,  ヽ.

Name: Anonymous 2013-09-01 1:00



:::::::::: ::: : : : : :   ___,,,... -‐- 、..,,__
:::: ::: : : : _,,.. - ''"´        _,,...,,_`ヽ、  T7
::: : : : /             `ヽ. `':, Y 'ァ'"´ ハ
   ,:'   ヽ、     ノ__  ト、.,__ノ   ! |ノ  /! |
く\ヘ_ゝ-、_ノ´`iコ二ハ、__ハ_,ヘ.    ,.ム/  . | !    ,,.. --────
 \ハ、_>‐''"´:.;:.:.:.:.:.:.:.:.:.';:.:.:.:.`'' ー''7-、_!__∠___!_/   /
_ノ´Y´/:.:./:./:.:.;':.:.:.i:.:.:.:.:.:.:.!:.:.:.ハ:.:.:.:ヽ.__,.ム、_ハ.、   ,'  あ 特 喘 今
L___,':.:!:.:.:.!:.:!、:;_!_;.:;ハ:.:.!、:_/;;::イ:.!:.:.:!:.:.';.:.:.:.:.キ `ヽ!  |.  げ 別 息 日
..└i:.:.:'、:.:.!.ハ__」__ハ! レ' ァーr-‐ァ'i7:.:.!:.:.:!:.:.:.:.:.!ュノ」   !.  る に. の は
  !:.:.:.:.ヽ:!〈'ヽ,.ハ`  '   i  r;ンi__;ハ__」:.:.:.:.:|/´    |.   わ 見 調
  |ハ___|:,ハ. 。 ゝ' :.:.:.:.:.. `"´,.,.,!:. o :!:.:.:.:.:.i    ∠.     逃 子
 ゼェ ';.:.:.:.! '"'"       u .,'.:.:.:.!:.|:.:.:.;.:;:'     |      し. が
. ,.、  ノ:i:.:..':、    i´ ̄ヽ.   ,/:.:.:.:;':.:!:.:.:.i/| ゼェ   .!      て 悪
( _) ,':.:.!:. ( )`>.、.,` -‐ ',,.イ/:.:.:.:.:.:.:! ,.-'-、     |        い
   i:.: ( ) :.:.:.ノ:.:.:.!`T'´ __,/:.:;':.:/'‐ /   ソ、.    !         か
   !:.::/.:.:.:/ ';!イ `7i´ ,':.:.:/:./!:: / `ーァ'´、 ヽ.  ',       ら
   !:/:.r'" ,.'´ /ヽ/ムレ'i.:.:.;':.:i rノ   /ー-、 ヽ、!,_ ヽ、.,_____________________
[__>「7」 /   ,.-、  |  !:.:.:! ,.:´ __  /  /`ヽrァヘ
 くノ:.:.:!rく_  ,./   'ー-、 [iコ' ! ´ ヽ. i  ./  /`〉 /i
 〈:.:.:.:.:iヽヘ>i/      ノi:.:.:,ハヽ、    ソ- '、_ノ_,.:'イン
  ヽヘ:.」 i7´iヽ、_____,.イi Lハ_」、 i `二´7'' ー-‐' i/
      i'  `'ー-'-- ' |'   ハ !   ` '' ー-‐'Y

Name: Anonymous 2013-09-01 2:31



                      /ヽ.
                (_,.、__)
             __,,.ィ'´ /  ヽ、
       ,. ァ ''"´ ̄/ ̄ ̄`7'' ー-ヽ、.,_
     ,. '"´アヽ--─----'"ヽ─ 、ハ ヽ、ヽ、
    / ァ'" ,.---、    ,. -‐-、 `ヽ、/`ヽヽ
   ./>、_ノ  i:7⌒ヽ;ヽ____/:/⌒i::::|    ヽ/',i
   i/     i::l '"´ ';:|-/:/ ̄/:::/、.    ヽ. ', !
   i      /ヽヽ、__rへ-イ___//  `ヽ.    Y:|  
   ト、/   !__ r>'´ ̄`''ー<ヘ-/   ',    !/
   !へ、_ r'7'´ ,  ハ  ハ___ ヽ!ヽ、_ L.i ._/!
    ヽ、へY  / -/‐! / !ァ-;!、 ヽ  Y/''"!_.ノ
       !  !./,アr! V ´ヒ_r!〉Yヘ|  ',〉´      ,.-,_
       ノヘ/ハ.!'ゞ' .    ""!. |ヽ、 i ヽ、   i^'く  !
   |ヽ、.,__  ノ !7、"  i´ ̄〉   ハ |  ハ__,,.ァ-‐'"  __.ン
   `'ーァ '"´/// >.、.,___ ,. イ|/'"´7'"<  _,,.- '"
     i  /〈//!,,.ィ'"く-v-イ// |::::::-{_,,.->'"i
    r-ゝィ'´{///:::7::::Y(ム〉:::/ ノ、___;:イi   /
    レヘ|`ァ'/〈::r::!:::::::Y:::::::::::!ハ   / i   〈    /〉
   /(//⌒i)^ー-'!、_::::::::::::}>ヘ  / /  i ',  ノ>{}くゝ
  / ノ l_,、_ノ_,.ァく::/-7‐-、::::(|ヽ〉、〈 /  ハ  ヽ、 /|
  〈 /「し'/ ゝ!ィ'´ ̄Y´ ̄`ヽ!:::::、:::ヽ、__,.'-ァ'、_,,. '":::::!
  Y `ー'__,イ::::::!、____,.!、____ノ! i、::::!::::::::::::::ヽ-ヘ:::=゚ω゚)
  ,,.-‐''":::rヘ:::::!、____,.ム、____,.ト、ヽ、!:::::::::ヽ、_l__(:::::/
}>'<{:-=・=-ヽハ_!. ×:7ハ × ',/i |イ二ヽ::::ン'‐'i/
ノ)´ `'ー‐''"´ヽ::!:`''ー'i::::::',-‐'ヘ/ン´   Y   (|
|/         i>く`! ̄!>< i
         ヽ、__.ノ  ヽ、_ノ

    蒋 叙周 - Shou Josyu - (生年不明)
    -- 、::: :::: ::: : :               /  今
     ヽ.   /i´`ヾ二ア''‐- 、      i  回
   で  ', ri ゝ、__ン「i、    ト 、    |  は
   .も   i r'7'´ヽ-'ヽ_ン、__,.イ   ヽ.  |  見
   次   | Y  ハi ハ  `ー'、i    i.  |  逃
   は   |イ i ./r'、ト !/_,ィ  i>r、_,rン  ',.  す
        ! !ハ!イトj   ァ;'-!、ハ,ゝ   i ∠.  わ
ヽ、.,___  ,/  /i7'  ,   ト__j〉! |   |   ヽ、_____
::: ::  :\|    ) .>、 r--,  "/! !   i
:: : :      / | iヽ、二_ イ //   ハ
:: :      〈 /ヽ,.- 、'ー</'   / .i
:       ヽ/    ヽ::::〈   /  /
        ,i、    /:::::/ ,'   i
     ___/  ´ ソ':::::::::i / /i  /
    rン'     /::::::::::::!/レi レ'ヽ


::: :: : : :  ,.'´ 二`ヽ、_____  ,. --- 、 : : :
  ┼   |::|'´ ̄ `ヽ;‐r''"<´__ `ヽヽ       ,. -─
     /ゝ、.,____,.ィ-'>、ヽ、  `ヽ!:::|     / 
:::: ::::  !_「 ̄`>---<`ヽ、.,_二ンヽ.   /   な
    r'" _>'"      ̄ヽ_7- 、   \ i.     い
 * 〈 !/  /   ハ     ヽ_/ヽ_.ノ '、|.    と
    /  i /| /i /  i  i   ヽ__,.へ,__ i    思
: : : : ::i  i / レ´ ̄!、 | / !.___i  iヽ、_ri、 |    え
::: :::  レ、,へi' ´ ̄ヽ  レ' , ! /`i  !   ∠、
     イ .7"       ´ ̄`ヽ!  ,ゝ .| |  `'' ー─
 +   ! /、    '     "/ゝ、!  | |     i
   。 / !/'ヽ.   ー ‐  ///  / ハ  _ __人 __ _
    〈  | / `ヽ、.____ / /   ./ / i   `Y´
    /ヽ! ハ  __/ i/__,.イ   /  i  ',     !
    i / /´  `ヽ:::::::/i  /   |   〉
   ノヾン´       i::::i ハ  i    ハ  〈
    ,.〈 ,       ノ::::|  ヽ!   / !  i

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