diff --git a/src/mol-data/structure/model/types.ts b/src/mol-data/structure/model/types.ts index 374a5392c0765fb5be6769601b731ca1d7253cbe..4a90f04c90e1d50e539ca8c7e19b2e208b404e18 100644 --- a/src/mol-data/structure/model/types.ts +++ b/src/mol-data/structure/model/types.ts @@ -7,10 +7,27 @@ import BitFlags from 'mol-base/utils/bit-flags' -const _esCache = Object.create(null); +const _esCache = (function () { + const cache = Object.create(null); + const letters: string[] = []; + for (let i = 'A'.charCodeAt(0); i <= 'Z'.charCodeAt(0); i++) letters[letters.length] = String.fromCharCode(i); + for (let i = 'a'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) letters[letters.length] = String.fromCharCode(i); + for (let i = '0'.charCodeAt(0); i <= '9'.charCodeAt(0); i++) letters[letters.length] = String.fromCharCode(i); + + for (const k of letters) { + cache[k] = k.toUpperCase(); + for (const l of letters) { + cache[k + l] = (k + l).toUpperCase(); + for (const m of letters) { + cache[k + l + m] = (k + l + m).toUpperCase(); + } + } + } + return cache; +}()); export interface ElementSymbol extends String { '@type': 'element-symbol' } export function ElementSymbol(s: string): ElementSymbol { - return _esCache[s] || (_esCache[s] = s.toUpperCase()); + return _esCache[s] || s.toUpperCase(); } export const enum EntityType { diff --git a/src/perf-tests/structure.ts b/src/perf-tests/structure.ts index 613782de8cdfbebcdfc64ca7da89bc6da17e1a8e..af1fa2f27e50f8b991b5c2cb7d86bcc2aceaef89 100644 --- a/src/perf-tests/structure.ts +++ b/src/perf-tests/structure.ts @@ -237,8 +237,8 @@ export namespace PropertyAccess { // } export async function run() { - const { structures, models } = await readCIF('./examples/1cbs_full.bcif'); - //const { structures, models } = await readCIF('e:/test/quick/1jj2_full.bcif'); + //const { structures, models } = await readCIF('./examples/1cbs_full.bcif'); + const { structures, models } = await readCIF('e:/test/quick/3j3q_full.bcif'); //const { structures, models } = await readCIF('e:/test/quick/3j3q_updated.cif'); // console.log(toMmCIFString('test', structures[0])); @@ -280,8 +280,8 @@ export namespace PropertyAccess { chainTest: Q.pred.inSet(P.chain.auth_asym_id, ['A', 'B', 'C', 'D']), residueTest: Q.pred.eq(P.residue.auth_comp_id, 'ALA') }); - const q0r = q(structures[0]); - console.log(toMmCIFString('test', Selection.union(q0r))); + // const q0r = q(structures[0]); + // console.log(toMmCIFString('test', Selection.union(q0r))); console.time('q1') q1(structures[0]);