Menu

#12 [RFC] deduplicate GetSystemXProp() code

open
nobody
None
5
2011-07-04
2011-07-04
Anonymous
No

A comment in galaxy.cpp hinted me into doing this "cleanup".
Does it looks sane enough ?

Please review, apply, comment...

Discussion

  • Klauss++

    Klauss++ - 2011-07-21

    There's a syntax to initialize structures that has explicit field names.
    It would be better to use it in the defaults structure, since SystemInfo could eventually change (actually it's quite likely to change). With explicit field names, the compiler will issue errors and warnings.

    If you post an updated patch, I'll check a few things but I think this could go in. Without explicit field names it's a bit fragile and will introduce bugs whenever someone changes SystemInfo (since the compiler will happily ignore missing or mismatching fields in many situations).

     
  • Klauss++

    Klauss++ - 2011-07-26

    Pity.

    Then the other option is to do explicit assignments:

    static bool initialized = false;
    static struct point p;
    if (!initialized) {
    initialized = true;
    p.x = xvalue;
    p.y = yvalue;
    }

    It's not as pretty, but is safe from changes to the underlying struct.

     
  • Pheonix Rising

    Pheonix Rising - 2011-11-19

    klauss, does your last change look good enough for commit?

     
  • Klauss++

    Klauss++ - 2011-11-19

    If it builds, yes.

     

Log in to post a comment.