by
Krull >> Mon, 30 Aug 1999 21:27:40 GMT
Does anyone know if its faster in Jade to write
vars
s : String[40];
rather than
vars
s : String;
It would seem reasonable that Jade could be faster with the first version as It knows how much space it has to allocate.
Anyone know for sure?
The physical storage for String variables is increased in multiples of 32 character increments (a character is 1 byte in an ANSI build and 2 in UNICODE). The only real differences between a restricted length and unbounded string are a) The restricted length string has the minimum of 64 or declared max length characters of storage preallocated b) Restricted length strings are subject to bounds checking, that is if you exceed the declared maximum size a 'string too long' exception is raised.
In your example declaration s : String[40], the string variable will have 40 characters of internal storage allocated up front, whereas if you store 40 characters in an unbounded string variable, it could start with either 32 characters growing to 64 in 1 increment, or 64 characters depending on the size of the string value first assigned to it. Beyond the initial 64 character initial size, both types of string are grown dynamically up to their defined upper limit in multiples of 32 characters. The handling of dynamic storage allocation for binary variables is the same but units are always bytes. For short strings (where short means <= 64 characters), defining a fixed length results in more efficient storage; however, be aware that physical implementations are subject to change.