Slower:
if (streln($str) >= 5) // ...
Faster:
if (isset($str[5])) // ...
Slower:
// ... lots of code that may set $var
if (isset($var)) // ...
Faster:
$var = null;
// ... lots of code that may set $var
if ($var !== null) // ...
Surprisingly, equal:
empty($e) === (Bool) $e // the latter gives an error if $e is unset, tho.
>>16
oops...
2147483647 != 2147483648
easily fixed: StringBuilder sb = new StringBuilder("x", 0x80000000)
and string s = new String('x', 0x80000000);
i haven't tested it, but filling 4GB (characters in c# are 16 bits) of memory with a single 16-bit value is almost certainly faster than reading 4GB from a file into memory.
>>23
Wrong, it shouldn't be O(1) in C.
If you can't write your own damn string library you're not worthy of being a C programmer. And no, you don't have to. You could just use a library already written by someone smarter than you. >>32
It does, as does ISO C you fucking incompentent programmer.
NOTICE THE GOD DAMN "const char" PART. MORON. IMBECILE. CRETIN. I FUCKING HATE YOU.
Name:
Anonymous2008-06-19 6:53
It does, as does ISO C you fucking incompentent programmer.
"If an attempt is made to modify an object defined with a const-qualified type through use
of an lvalue with non-const-qualified type, the behavior is undefined. If an attempt is
made to refer to an object defined with a volatile-qualified type through use of an lvalue
with non-volatile-qualified type, the behavior is undefined.113)"
"undefined" means that ISO C doesn't say that it can't modify the string.
Also, POSIX doesn't say you can't do this: #define const /* lol */
Name:
Anonymous2008-06-19 7:28
>>33
Yes it should. Making strings simply a null-terminated character array was a bad design decision.
Name:
Anonymous2008-06-19 7:53
>>20
Yeah, yeah, I had an = too much. (strlen($x) > $y) === isset($x[$y])
>>35
Yeah, C had a lot of bad design decisions that we only realised later on.
Name:
Anonymous2008-06-19 9:01
>>37 Yeah, C had a lot of bad design decisions that we only realised later on.
LAWL
Name:
Anonymous2008-06-19 9:18
>>38
I'm sure he meant 66we99 as in 66the worldwide community of programming professionals and researchers99, of which /prog/ is clearly an eminent member.
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy