|
Veteran Member
Join Date: Oct 2004
Location: US
|
03-16-2006
, 13:41
|
#4
|
Quote:
Originally Posted by AMWiki
A common mistake is to write code like this:
Code:
new string[256] = "something long"
for (new i=0; i<strlen(string); i++)
//...code
This plays off a similar principle from before: cache results. The compiler will actually recompute your string length on each iteration of the loop. This will have even worse effects if your string changes mid-loop. A more sensible method is:
Code:
new string[256] = "something long"
new len = strlen(string)
for (new i=0; i<len; i++)
//...code
|
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116
I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
|
|
|
|