[mercury-users] string_stream impl, re: redirecting output to streams

Ralph Becket rafe at cs.mu.OZ.AU
Thu Feb 16 13:55:44 AEDT 2006


Ian MacLarty, Wednesday, 15 February 2006:
> Not in principle, but I think you might have problems with the C code 
> that ultimately does things with the strings (for example instead of 
> passing the string to printf to write it out, you'd have to have extra 
> code to handle nulls in the string which might be an efficiency 
> problem).

Many functions in the string library are O(n) rather than O(1) because
they always do string bounds checking.  It would be better to define

typedef struct { MR_Integer length; const char chars[] } MR_String;

and then pass MyStr->chars to C rather than just MyStr.

I think this would be a Good Change to make.

-- Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list