[REBOL] Re: To-pair vs as-pair
From: anton:lexicon at: 2-Jan-2003 11:24
Yes, as-pair is quite useful.
Keep in mind that if you use these
functions in a tight loop that draws
some graphics, for example, you can
get some speed by gutting the functions.
Let's look at the sources:
>> ?? as-pair
as-pair: func [
"Combine X and Y values into a pair."
x [number!] y [number!]
][
to-pair reduce [to-integer x to-integer y]
]
>> ?? to-pair
to-pair: func ["Converts to pair value." value "Value to convert"][to pair!
:value]
You can see that as-pair makes three mezzanine function calls.
This will slow you down in a tight loop, so instead,
you could just do everything yourself:
to pair! reduce [to integer! x to integer! y]
That will be much faster.
(And also backwards compatible to last full version of view 1.2.1)
Anton.