From feb04b60e04d5f533a5ee15e7b9ca2edb03eec01 Mon Sep 17 00:00:00 2001 From: Greg Landrum Date: Tue, 22 Nov 2011 06:53:48 +0000 Subject: [PATCH] periodic table optimization --- Code/GraphMol/PeriodicTable.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Code/GraphMol/PeriodicTable.h b/Code/GraphMol/PeriodicTable.h index 9c5a47e8f..b46dce132 100644 --- a/Code/GraphMol/PeriodicTable.h +++ b/Code/GraphMol/PeriodicTable.h @@ -77,8 +77,14 @@ namespace RDKit { } //! overload int getAtomicNumber( const std::string &elementSymbol ) const { - PRECONDITION(byname.count(elementSymbol),"Element '" + elementSymbol +"' not found"); - int anum = byname.find(elementSymbol)->second; + // this little optimization actually makes a measurable difference + // in molecule-construction time + int anum=-1; + if(elementSymbol=="C") anum=6; + else if(elementSymbol=="N") anum=7; + else if(elementSymbol=="O") anum=8; + else anum = byname.find(elementSymbol)->second; + POSTCONDITION(anum>-1,"Element '" + elementSymbol +"' not found"); return anum; }