-
Notifications
You must be signed in to change notification settings - Fork 170
Description
There are a lot of codes for checking which atom IElement object is.
For example,
if (atom.getSymbol().equals("H")) { ... }
if (!(bond.getBegin().getSymbol().equals("H") && bond.getEnd().getSymbol().equals("H"))) { ... }
These can be modified like the following and which should show better performance.
if (atom.getAtomicNumber() == 1) { ... }
if (!(bond.getBegin().getAtomicNumber() == 1 && bond.getEnd().getAtomicNumber() == 1)) { ... }
In fact, current implementation of getSymbol() in org.openscience.cdk.Element.java get the symbol through Elements.ofNumber(atomicNumber)
method. It is possible to implement an Element class in which getSymbol() returns "H" and getAtomicNumber() returns 5, but it is nonsense to think about such a thing.
I implemented such changes with NCDK, and it seems to work.