KUNAI-static-analyzer icon indicating copy to clipboard operation
KUNAI-static-analyzer copied to clipboard

Rewrite DEX classes avoiding over use of std::shared_ptr

Open Fare9 opened this issue 2 years ago • 1 comments

In order to improve performance avoid overuse of std::shared_ptr, keeping it only in very connected components (for example IRGraph and Graphs of basic blocks). In other cases, it is better to keep ownership in just one object (use of std::unique_ptr), there's no need to share ownership of many objects. A raw pointer can be returned in some cases when read access is needed.

Another interesting utility, whenever we use a vector of objects, we can do the next:

  using object_t = std::vector<Object*>;

And from these we could try to return iterators in order to go over them in case a user wants to go over all the data structure.

All these improvements will also be helpful for creating the bindings for other languages, since it does not use many shared_ptr, and there's no need to keep counter for number of references, etc.

A new branch will be created for doing all these changes, so we will avoid having issues.

Fare9 avatar Oct 28 '22 22:10 Fare9

Current branch https://github.com/Fare9/KUNAI-static-analyzer/tree/refactoring includes many of the changes here proposed, also fix an important issue regarding performance. All these changes have been tested, and currently all these changes are being tested against Androguard with a benchmarking.

Fare9 avatar Nov 29 '22 11:11 Fare9