Skip to content

Increase static usage and eliminate singletons to improve global scope & tersness #1734

@ghost

Description

Currently code such as:

Display.getInstance().callSerially(() -> {...});

Or

NetworkManager.getInstance().addToQueue(...);

Etc. is quite common. We need to unify all of these API's into static API's that would serve as the actual implementation E.g.:

CN1.callSerially(() -> {...});
CN1_IO.addToQueue(...);

This has two advantage, the first is in tesness as we could even use static import which would allow:

callSerially(() -> {...});
addToQueue(...);

The second advantage is in performance as the getInstance() call would be eliminated (it does have a cost on iOS which doesn't have a JIT). But it can be even faster assuming we eliminate the suclassing of the CodenameOneImplementation class and just replace it with the real implementation per platform. This would eliminate virtual calls and would allow the static compiler to optimize deep into the CodenameOneImplementation class. Event if we don't do that the performance difference should be noticeable on iOS and possibly Android.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions