Xref: utzoo comp.lang.c:11022 comp.lang.fortran:849
Path: utzoo!attcan!uunet!seismo!esosun!ucsdhub!hp-sdd!ncr-sd!steves
From: steves@ncr-sd.SanDiego.NCR.COM (Steve Schlesinger)
Newsgroups: comp.lang.c,comp.lang.fortran
Subject: += in C
Message-ID: <2314@ncr-sd.SanDiego.NCR.COM>
Date: 30 Jun 88 19:23:14 GMT
Organization: NCR Corporation, Rancho Bernardo
Lines: 27



I tried email this directly but it bounced.
Sorry (to the original poster) for the delay in answering.
Sorry to everyone else if it was aleady answered and I missed it.


In article <20039@beta.UUCP> you write:
>To some extent, the lack of detailed knowledge
>of C is my reason for not using it. (For example: why is 'a+=b' faster
>than 'a=a+b'?  Seems to me that the two are identical and should generate
>the exact same code.)


When optimized, yes they are the same.

Without optimization consider

	a[i][j] = a[i][j] + b
vs.
	a[i][j] += b

In the second case the address a[i][j] is computed only once and reused.
This is faster both at compilation and execution times.

An optimizer would convert the first to the second.
--