Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!ames!ucbcad!ucbvax!decvax!tektronix!teklds!copper!stevesu From: stevesu@copper.UUCP Newsgroups: comp.lang.c Subject: Re: Copying a constant number of bytes Message-ID: <1120@copper.TEK.COM> Date: Sat, 13-Jun-87 17:00:39 EDT Article-I.D.: copper.1120 Posted: Sat Jun 13 17:00:39 1987 Date-Received: Sun, 14-Jun-87 18:36:48 EDT References: <900@bloom-beacon.MIT.EDU> Organization: Tektronix Inc., Beaverton, Or. Lines: 23 In article <900@bloom-beacon.MIT.EDU>, newman@athena.mit.edu (Ron Newman) writes: > I want to copy a constant number of bytes... Which is the more > efficient method for most compilers and machines currently in use? > > Method 1) > > bcopy ((char *)a, (char *)b, NBYTES); > > Method (1) has the disadvantage that it always involves a subroutine > call and return. How sure are you that this is a disadvantage? I always use bcopy, and I've never found it to be an efficiency bottleneck. Until you've profiled your code and proved that bcopy itself or the associated function call overhead is significant, don't fuss with other methods. (BTW, the structure-assignment trick does work, under "reasonable" compilers, and produces nice, tight code, but it certainly "looks" fishy enough that I'd be loathe to use it in bulletproof, portable code even if somebody can come up with an argument that it's legal.) Steve Summit stevesu@copper.tek.com