Content deleted Content added
Really not a problem. |
Assessment: banner shell, Computing (Rater) |
||
(8 intermediate revisions by 5 users not shown) | |||
Line 1:
{{WikiProject
{{WikiProject Computing}}
}}
The page originally had the following:
Line 36 ⟶ 38:
This sort of optimization is frequently seen in JavaScript, where iterating over an array or a list of DOM nodes can often be sped up by precalculating the length of the array or node list either outside the loop or (more commonly) in the initialization of the loop variables (e.g., <code>for(var i=0, max=someList.length; i < max; i++)</code> instead of <code>for(var i=0; i<someList.length; i++)</code>, avoiding the repetitive computation -- in some JavaScript implementations -- of <code>someList.length</code>). If anyone thinks this would be a useful addition to the article, I'll dig up some references and put it in. [[User:Ubernostrum|Ubernostrum]] 08:43, 5 July 2007 (UTC)
== Somethign wrong here in the example ==
There is no need for this loop at all. Just multiply the sodding thing up by calcval and then round off the end. Something is wrong here.
[[User:SimonTrew|SimonTrew]] ([[User talk:SimonTrew|talk]]) 21:56, 9 March 2009 (UTC)
:I've replaced the (slightly weird) example with another, hopefully better, example. [[User:Alksentrs|Alksentrs]] ([[User talk:Alksentrs|talk]]) 01:33, 10 March 2009 (UTC)
::OK great. I am gonna check it over with my subbing eye. I hope you don't mind, I am sure it is fine, Wikipedia is great and I love it a lot and everyone who puts into it, but if something is wrong you have to say so.
== a[i] is a multiplication ==
:"''[...] strength reduction could remove the two multiplications inside the loop (6*i and a[i]) [...]''"
Via [[C syntax]] and [[pointer arithmetic]], '''a[i]''' can also be interpreted as '''*(a + i)'''. Can someone tell where the hidden multiplication is taking place? --[[User:Abdull|Abdull]] ([[User talk:Abdull|talk]]) 12:56, 29 October 2010 (UTC)
:When doing pointer arithmetic, the index needs to be scaled by the pointer target's size: if <code>a</code> has type <code>int*</code>, then <code>*(a + i)</code> is equal to <code>*(int*) (((char*) a) + (i * sizeof(int)))</code>. [[User:Alksentrs|Alksentrs]] ([[User talk:Alksentrs|talk]]) 16:44, 29 October 2010 (UTC)
==Code motion==
Should [[code motion]] link here? [[Special:Contributions/70.247.173.255|70.247.173.255]] ([[User talk:70.247.173.255|talk]]) 00:46, 20 May 2012 (UTC)
|