@@ -14,6 +14,7 @@ public final class TableRegionFingerprintService {
1414 private static final String REGION_WALL = "wall" ;
1515 private static final String REGION_DORA = "dora" ;
1616 private static final String REGION_CENTER = "center" ;
17+ private static final SeatRegionKeys [] SEAT_REGION_KEYS = createSeatRegionKeys ();
1718
1819 public Map <String , Long > precomputeRegionFingerprints (TableRenderSubject session , TableRenderSnapshot snapshot ) {
1920 Map <String , Long > fingerprints = new HashMap <>();
@@ -23,10 +24,11 @@ public Map<String, Long> precomputeRegionFingerprints(TableRenderSubject session
2324 fingerprints .put (REGION_CENTER , this .centerFingerprint (snapshot ));
2425 for (SeatWind wind : SeatWind .values ()) {
2526 TableSeatRenderSnapshot seat = snapshot .seat (wind );
26- fingerprints .put (this .seatRegionKey ("visual" , wind ), this .seatVisualFingerprint (session , wind ));
27- fingerprints .put (this .seatRegionKey ("labels" , wind ), this .seatLabelFingerprint (session , snapshot , seat ));
28- fingerprints .put (this .seatRegionKey ("sticks" , wind ), this .stickFingerprint (snapshot , seat ));
29- fingerprints .put (this .seatRegionKey ("hand-public" , wind ), this .handPublicFingerprint (snapshot , seat ));
27+ SeatRegionKeys keys = SEAT_REGION_KEYS [wind .index ()];
28+ fingerprints .put (keys .visual (), this .seatVisualFingerprint (session , wind ));
29+ fingerprints .put (keys .labels (), this .seatLabelFingerprint (session , snapshot , seat ));
30+ fingerprints .put (keys .sticks (), this .stickFingerprint (snapshot , seat ));
31+ fingerprints .put (keys .handPublic (), this .handPublicFingerprint (snapshot , seat ));
3032 }
3133 return Map .copyOf (fingerprints );
3234 }
@@ -248,8 +250,18 @@ private long stickFingerprint(TableRenderSnapshot snapshot, TableSeatRenderSnaps
248250 return builder .value ();
249251 }
250252
251- private String seatRegionKey (String region , SeatWind wind ) {
252- return region + ":" + wind .name ();
253+ private static SeatRegionKeys [] createSeatRegionKeys () {
254+ SeatWind [] winds = SeatWind .values ();
255+ SeatRegionKeys [] keys = new SeatRegionKeys [winds .length ];
256+ for (SeatWind wind : winds ) {
257+ keys [wind .index ()] = new SeatRegionKeys (
258+ "visual:" + wind .name (),
259+ "labels:" + wind .name (),
260+ "sticks:" + wind .name (),
261+ "hand-public:" + wind .name ()
262+ );
263+ }
264+ return keys ;
253265 }
254266
255267 private static FingerprintBuilder fingerprintBuilder (int capacity ) {
@@ -284,4 +296,7 @@ private void mix(char value) {
284296 this .hash *= FNV_PRIME ;
285297 }
286298 }
299+
300+ private record SeatRegionKeys (String visual , String labels , String sticks , String handPublic ) {
301+ }
287302}
0 commit comments