Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!bu-cs!bzs From: bzs@bu-cs.BU.EDU (Barry Shein) Newsgroups: comp.lang.c Subject: Re: Portable C vs Efficient C or "Cost of Portability" Message-ID: <6980@bu-cs.BU.EDU> Date: Mon, 27-Apr-87 00:42:40 EDT Article-I.D.: bu-cs.6980 Posted: Mon Apr 27 00:42:40 1987 Date-Received: Tue, 28-Apr-87 02:03:15 EDT References: <213@pyuxe.UUCP> <636@edge.UUCP> <1316@frog.UUCP> <658@edge.UUCP> <1017@ubc-cs.UUCP> <682@edge.UUCP> <1103@epimass.UUCP> Organization: Boston U. Comp. Sci. Lines: 34 In-reply-to: jbuck@epimass.UUCP's message of 26 Apr 87 20:14:26 GMT Posting-Front-End: GNU Emacs 18.41.4 of Mon Mar 23 1987 on bu-cs (berkeley-unix) Everyone, in retort to Doug Pardee's note about character handling in C vs Asm mentions library routines (and possibly inline asm.) How about the now well established structure assignment: struct string { char thechars[STRSIZE]; }; If I declare s1 and s2 to be struct strings and do a: s1 = s2; my Vax generates a movc3, my Encore (NS32K) generates a MOVSD instruction, my Sun (68K) generates a tight dbra loop and my IBM3090 generates a MVCL, all of that is quite optimal if you want to save yourself a trip to the prin-ops. I think the problem is (if there is one) that most (all?) machine architectures don't have a lot to deal with null term'd strings. Oh, you can use a LOCC on a Vax or even a TRT on an IBM (370, not PC), minor, but most assembler programmers will go for fixed length string formats that will match the hardware (not a slur, it's the right thing if you're after raw speed and can stand some loss in flexibility.) I can't argue with the success of C's null terminated string formats, but I've coded in a BCPL string style in C programs to speed up certain operations and I still have all 10 of my fingers. It just doesn't often matter much (tho you want to profile strcpy() when your text processing slows down, you might change your mind.) -Barry Shein, Boston University