pike.git/
src/
builtin_functions.c
Branch:
Tag:
Non-build tags
All tags
No tags
2014-02-26
2014-02-26 13:27:47 by Per Hedbor <ph@opera.com>
ea315f342abfc7816a5b36fc82d63b27885ac4fe (
11
lines) (+
10
/-
1
)
[
Show
|
Annotate
]
Branch:
per/rdrnd
4x faster random_string.
826:
INT_TYPE len, e; get_all_args("random_string",args,"%+",&len); ret = begin_shared_string(len);
-
for(e=0;e<len;e++) ret->str[e] = DO_NOT_WARN((char)my_rand());
+
+
/* Note: Assumes pike_string->str is aligned on a 4 byte boundary
+
* (it is, currently)
+
*/
+
for(e=
3;e<len;e+=sizeof(INT32))
+
((unsigned INT32 *)(ret->str+e-3))[
0
] = DO_NOT_WARN(my_rand())
;
+
for(;
e<len;e++)
+
ret->str[e] = DO_NOT_WARN((char)my_rand());
+
pop_n_elems(args); push_string(end_shared_string(ret)); }