Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CODE
- obj = { x = 5, y = 6 };
- its = 1000000;
- t = ftime();
- for( i = 0; i < its; ++i )
- {
- a = obj.x;
- a = obj.y;
- }
- println( "old method: " $ ftime() - t $ " seconds" );
- t = ftime();
- for( i = 0; i < its; ++i )
- {
- a = obj.0;
- a = obj.1;
- }
- println( "new method: " $ ftime() - t $ " seconds" );
- // OUTPUT
- old method: 0.542 seconds
- new method: 0.384 seconds
- // NEW SYNTAX CONCEPT
- obj = { x = 5, y = 6 };
- assume obj = x, y; // validated by name, order of parameters here must match order of insertion (which is equal to the order of the internal array) in the object
- for( i = 0; i < its; ++i )
- {
- a = obj.x; // translated to obj.0 in bytecode
- a = obj.y; // translated to obj.1 in bytecode
- }
- // NEW SYNTAX CONCEPT v2
- obj = { x = 5, y = 6 };
- typedef myObject = x, y; // same as "assume" but only defines the structure, doesn't actually assume the properties of a variable name
- ...
- assume obj : myObject; // allows keeping the actual property list with the object, as well as avoiding the need to re-specify all of the parameters each time a function uses the object a lot
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement