[Proj] Code style in Proj

Even Rouault even.rouault at spatialys.com
Sun Apr 22 07:26:51 EST 2018


On samedi 21 avril 2018 15:46:22 CEST Kurt Schwehr wrote:
> Hi all,
> 
> I've been thinking about what is possible with the Proj code base with an
> assumption that the code must be C89/C90 compatible.  I played around for a
> few in godbolt with PJ_august.c (because it's small) and ended up with
> this.  I tried to be aggressive as I could.  I think my modified version is
> likely to be more static analyzer friendly. 

I hope they are intelligent enough to make sense of the original code ;-)

> - Don't have assignments hidden inside expressions

Definitely +1 on this ! 

To avoid the modification of lp.lam in the cos(), 

> const double c = 1.0 + c1 * cos(lp.lam *= .5);
> const double x1 = sin(lp.lam) *  c1 / c;

this part could also be re-written, as

const double half_lam = 0.5 * lp.lam;
const double c = 1.0 + c1 * cos(half_lam);
const double x1 = sin(half_lam) *  c1 / c;



-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/proj/attachments/20180422/5dc21a6c/attachment.htm 


More information about the Proj mailing list