Re: Object damage code...

From: George (greerga@DRAGON.HAM.MUOHIO.EDU)
Date: 08/23/97


On Sat, 23 Aug 1997, Zizazat Lazuras wrote:

>> You can make a 'const char *mesg' and just do:
>> mesg = "This looks indestructible\r\n";
>>
>> then:
>> send_to_char(mesg);
>>
>> That'll save the time of copying the constant string into the variable.
>
>This I am less clear on, but I have some ideas about what you are saying.
>I think if I get it working the other way first I may come back to this.

Well, the point in that version is that it is much faster to simply assign
a pointer to a string than it is to copy the whole string into a variable.

CircleMUD does this in a couple places, doing a strcpy() into a buffer
instead of just defining a char* and pointing it at the correct message.
The additional plus of that is you can even return the string without a
static char[] or malloc().  You want to define it as const though so you
don't attempt to write in the middle of a string constatnt.

 --
greerga@muohio.edu me@null.net | Genius may have its limitations, but stupidity
http://www.muohio.edu/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST