Skip to content

Commit

Permalink
Remove mBindingsToNodes in DataFlowGraph
Browse files Browse the repository at this point in the history
Summary: These don't need to be cached, they're a field we can just get off GraphBinding

Reviewed By: marco-cova

Differential Revision: D6259245

fbshipit-source-id: 2da6f22741eb98e3ae60c9b7f2b5d5eae657d94a
  • Loading branch information
astreet authored and facebook-github-bot committed Nov 10, 2017
1 parent 07010af commit aff1c6f
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public static DataFlowGraph create(TimingSource timingSource) {
private final CopyOnWriteArrayList<GraphBinding> mBindings = new CopyOnWriteArrayList<>();
private final ArrayList<ValueNode> mSortedNodes = new ArrayList<>();
private final ArraySet<ValueNode> mFinishedNodes = new ArraySet<>();
private final SimpleArrayMap<GraphBinding, ArraySet<ValueNode>> mBindingToNodes =
new SimpleArrayMap<>();

private boolean mIsDirty = false;

Expand All @@ -77,7 +75,6 @@ public void register(GraphBinding binding) {
throw new RuntimeException("Expected added GraphBinding to be active: " + binding);
}
mBindings.add(binding);
mBindingToNodes.put(binding, binding.getAllNodes());
if (mBindings.size() == 1) {
mTimingSource.start();
}
Expand All @@ -92,7 +89,6 @@ public void unregister(GraphBinding binding) {
if (!mBindings.remove(binding)) {
throw new RuntimeException("Tried to unregister non-existent binding");
}
mBindingToNodes.remove(binding);
if (mBindings.isEmpty()) {
mTimingSource.stop();
}
Expand Down Expand Up @@ -126,8 +122,8 @@ private void regenerateSortedNodes() {
final ArraySet<ValueNode> leafNodes = ComponentsPools.acquireArraySet();
final SimpleArrayMap<ValueNode, Integer> nodesToOutputsLeft = new SimpleArrayMap<>();

for (int i = 0, bindingsSize = mBindingToNodes.size(); i < bindingsSize; i++) {
final ArraySet<ValueNode> nodes = mBindingToNodes.valueAt(i);
for (int i = 0, bindingsSize = mBindings.size(); i < bindingsSize; i++) {
final ArraySet<ValueNode> nodes = mBindings.get(i).getAllNodes();
for (int j = 0, nodesSize = nodes.size(); j < nodesSize; j++) {
final ValueNode node = nodes.valueAt(j);
final int outputCount = node.getOutputCount();
Expand Down Expand Up @@ -208,10 +204,10 @@ private boolean areInputsFinished(ValueNode node) {
private void notifyFinishedBindings() {
// Iterate in reverse order since notifying that a binding is finished results in removing
// that binding.
for (int i = mBindingToNodes.size() - 1; i >= 0; i--) {
final GraphBinding binding = mBindingToNodes.keyAt(i);
for (int i = mBindings.size() - 1; i >= 0; i--) {
final GraphBinding binding = mBindings.get(i);
boolean allAreFinished = true;
final ArraySet<ValueNode> nodesToCheck = mBindingToNodes.valueAt(i);
final ArraySet<ValueNode> nodesToCheck = binding.getAllNodes();
for (int j = 0, nodesSize = nodesToCheck.size(); j < nodesSize; j++) {
final ValueNode node = nodesToCheck.valueAt(j);
if (!mFinishedNodes.contains(node)) {
Expand Down

0 comments on commit aff1c6f

Please sign in to comment.