Skip to content

Commit 3d396f7

Browse files
committed
optimize swap table initialization
1 parent 24c785e commit 3d396f7

File tree

1 file changed

+7
-6
lines changed
  • common-tools/clas-detector/src/main/java/org/jlab/detector/swaps

1 file changed

+7
-6
lines changed

common-tools/clas-detector/src/main/java/org/jlab/detector/swaps/SwapTable.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ public SwapTable(IndexedTable fromTrans,IndexedTable toTrans) {
7070

7171
this.table = new IndexedTable(VAR_NAMES.length,String.join(":",VAR_NAMES));
7272

73-
for (int row=0; row<fromTrans.getRowCount(); row++) {
73+
// loop over the rows in the translation table:
74+
for (Object key : fromTrans.getList().getMap().keySet()) {
7475

75-
// crate/slot/channel is the base for mapping between the two tables:
76-
final int crate = Integer.parseInt((String)fromTrans.getValueAt(row,0));
77-
final int slot = Integer.parseInt((String)fromTrans.getValueAt(row,1));
78-
final int channel = Integer.parseInt((String)fromTrans.getValueAt(row,2));
79-
final long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(crate, slot, channel);
76+
// get the hash for this row:
77+
int crate = IndexedTable.DEFAULT_GENERATOR.getIndex((long)key, 0);
78+
int slot = IndexedTable.DEFAULT_GENERATOR.getIndex((long)key, 1);
79+
int channel = IndexedTable.DEFAULT_GENERATOR.getIndex((long)key, 2);
80+
long hash = IndexedTable.DEFAULT_GENERATOR.hashCode(crate, slot, channel);
8081

8182
// load the previous and current values of sector/layer/component/order:
8283
boolean diff = false;

0 commit comments

Comments
 (0)