Skip to content

Commit

Permalink
Update NetworkTable.java
Browse files Browse the repository at this point in the history
  • Loading branch information
srimanachanta committed Oct 13, 2023
1 parent ec1ad50 commit 1f5cb1a
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions ntcore/src/main/java/edu/wpi/first/networktables/NetworkTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -532,27 +532,27 @@ public int addSubTableListener(SubTableListener listener) {
return m_inst.addListener(
new String[] {m_pathWithSep},
EnumSet.of(NetworkTableEvent.Kind.kPublish, NetworkTableEvent.Kind.kImmediate),
new Consumer<NetworkTableEvent>() {
final Set<String> m_notifiedTables = new HashSet<>();

@Override
public void accept(NetworkTableEvent event) {
if (event.topicInfo == null) {
return; // should not happen
}
String relativeKey = event.topicInfo.name.substring(prefixLen);
int endSubTable = relativeKey.indexOf(PATH_SEPARATOR);
if (endSubTable == -1) {
return;
}
String subTableKey = relativeKey.substring(0, endSubTable);
if (m_notifiedTables.contains(subTableKey)) {
return;
}
m_notifiedTables.add(subTableKey);
listener.tableCreated(parent, subTableKey, parent.getSubTable(subTableKey));
}
});
new Consumer<>() {
final Set<String> m_notifiedTables = new HashSet<>();

@Override
public void accept(NetworkTableEvent event) {
if (event.topicInfo == null) {
return; // should not happen
}
String relativeKey = event.topicInfo.name.substring(prefixLen);
int endSubTable = relativeKey.indexOf(PATH_SEPARATOR);
if (endSubTable == -1) {
return;
}
String subTableKey = relativeKey.substring(0, endSubTable);
if (m_notifiedTables.contains(subTableKey)) {
return;
}
m_notifiedTables.add(subTableKey);
listener.tableCreated(parent, subTableKey, parent.getSubTable(subTableKey));
}
});
}

/**
Expand Down

0 comments on commit 1f5cb1a

Please sign in to comment.