Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.

Commit 391a0a9

Browse files
committed
Simplified TransportHints class.
* Replaced internal map with simple boolean. * Fixed initialization bug. * Fixed code style.
1 parent 7ae94f6 commit 391a0a9

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,33 @@
11
package org.ros.node.topic;
22

3-
import java.util.Map;
4-
5-
import org.ros.internal.transport.ConnectionHeaderFields;
63
import org.ros.node.ConnectedNode;
74

8-
import com.google.common.collect.Maps;
9-
105

116
/**
127
* Provides a way of specifying network transport hints to
13-
* {@link ConnectedNode#newSubscriber(String, String)} and
14-
* {@link ConnectedNode#newSubscriber(org.ros.namespace.GraphName, String)}.
8+
* {@link ConnectedNode#newSubscriber(org.ros.namespace.GraphName, String, TransportHints)} and
9+
* {@link ConnectedNode#newSubscriber(String, String, TransportHints)}.
1510
*
1611
* @author [email protected] (Stefan Glaser)
1712
*/
1813
public class TransportHints {
1914

20-
Map<String, String> options;
15+
private boolean tcpNoDelay;
2116

22-
public TransportHints() {
23-
this.options = Maps.newConcurrentMap();
17+
public TransportHints() {
18+
this(false);
2419
}
2520

2621
public TransportHints(boolean tcpNoDelay) {
27-
tcpNoDelay(tcpNoDelay);
22+
this.tcpNoDelay = tcpNoDelay;
2823
}
2924

30-
public TransportHints tcpNoDelay(boolean nodelay) {
31-
options.put(ConnectionHeaderFields.TCP_NODELAY, nodelay ? "1" : "0");
32-
25+
public TransportHints tcpNoDelay(boolean tcpNoDelay) {
26+
this.tcpNoDelay = tcpNoDelay;
3327
return this;
3428
}
3529

3630
public boolean getTcpNoDelay() {
37-
return "1".equals(options.get(ConnectionHeaderFields.TCP_NODELAY));
38-
}
39-
40-
public Map<String, String> getOptions() {
41-
return options;
31+
return tcpNoDelay;
4232
}
4333
}

0 commit comments

Comments
 (0)