Given two solutions:
1.====================================================
class A {
  final int b;
  final C e;
  class C {
    final int D() {
      return b;
    }
  };
  void create() {
    e = C();
  };
};

or 2.: ================================================

class C {
  final array b;
  final array D() {
    return b;
  };
  void create(array _b) {
    b = _b;
  };
};

class A {
  final array b;
  final C e;
  void create() {
    e = C(b);
  };
};
====================================================

Assuming that there are (a lot) more other members and
methods in both classes (which are accessed within the
class, not cross-class), and further assuming that
the A class is being instantiated a *lot*:
What would the runtime impact of these two approaches considering
CPU time and memory used?

I would guess that solution 1 would be slightly more
efficient, both memory and CPU-wise.
Or am I overlooking something here where due to the
nested stack frames of solution 1, the actual CPU
or memory usage is higher than expected?
-- 
Stephen.
  • Performance/memory... Stephen R. van den Berg

Reply via email to