pure-c / purec

C backend for PureScript
234 stars 8 forks source link

Redundant variable assignments and indirect values #41

Closed felixSchl closed 6 years ago

felixSchl commented 6 years ago

When looking into #40, I discovered this:

    const purs_any_t * b$$$ =
      NULL;;
    b$$$ =
      ({
        const purs_any_t * * $ivalue =
          purs_indirect_value_new();;
        const purs_any_t * $value =
          NULL;;
        purs_indirect_value_assign(
          $ivalue,
          $value
        );
        $value;
      });
    b$$$ =
      ({
        const purs_any_t * * $ivalue =
          purs_indirect_value_new();;
        const purs_any_t * $value =
          NULL;;
        purs_indirect_value_assign(
          $ivalue,
          $value
        );
        $value;
      });
    b$$$ =
      ({
        const purs_any_t * * $ivalue =
          purs_indirect_value_new();;
        const purs_any_t * $value =
          NULL;;
        purs_indirect_value_assign(
          $ivalue,
          $value
        );
        $value;
      });
    b$$$ =
      ({
        const purs_any_t * * $ivalue =
          purs_indirect_value_new();;
        const purs_any_t * $value =
          NULL;;
        purs_indirect_value_assign(
          $ivalue,
          $value
        );
        $value;
      });

Firstly, why is b'' ("b$$$") re-assigned over and over again and secondly, what is going on with the indirect variables here?

This does not appear to break anything, but is messy, causes unnecessary heap allocations, and should be removed.