<commit_before>package com.chap.memo.memoNodes.model;

import java.util.ArrayList;
import java.util.HashSet;

import com.chap.memo.memoNodes.MemoNode;
import com.chap.memo.memoNodes.bus.MemoReadBus;
import com.chap.memo.memoNodes.bus.MemoWriteBus;
import com.eaio.uuid.UUID;

public class ArcList {
	MemoReadBus readBus = MemoReadBus.getBus();
	MemoWriteBus writeBus = MemoWriteBus.getBus();
	long lastUpdate = 0;

	// UUID[] nodes = new UUID[0];
	ArrayList<ArcOp> arcops = null;

	int type; // 0: parent list, 1:child list
	UUID nodeId;

	private long timestamp;

	public ArcList(UUID nodeId, int type) {
		this.type = type;
		this.nodeId = nodeId;
	}

	public long getTimestamp_long() {
		return this.timestamp;
	}

	public UUID[] update() {
		if (true|| this.arcops == null || readBus.opsChanged(lastUpdate)) {
			if (true||this.arcops == null) {
				this.arcops = readBus.getOps(nodeId, type, 0);
			} else {
				this.arcops.addAll(readBus.getOps(nodeId, type, lastUpdate));
			}
			lastUpdate = System.currentTimeMillis();
		}
		return ops2nodes();
	}

	public ArrayList<MemoNode> getNodes(long timestamp) {
		if (this.arcops == null) {
			this.arcops = readBus.getOps(nodeId, type, timestamp, 0);
		} else {
			this.arcops.addAll(readBus.getOps(nodeId, type, timestamp,
					lastUpdate));
		}
		UUID[] nodes = ops2nodes();
		ArrayList<MemoNode> result = new ArrayList<MemoNode>(nodes.length);
		for (UUID id : nodes) {
			result.add(readBus.find(id, timestamp));
		}
		return result;
	}

	public UUID[] getNodesIds() {
		return update();
	}

	public ArrayList<MemoNode> getNodes() {
		UUID[] nodes = update();
		ArrayList<MemoNode> result = new ArrayList<MemoNode>(nodes.length);
		for (UUID id : nodes) {
			result.add(new MemoNode(id));
		}
		return result;
	}

	public int getLength() {
		return update().length;
	}

	public void addNode(UUID other) {
		if (this.arcops == null) { // small performance gain
			update();
		}
		UUID[] arc = new UUID[2];
		arc[this.type] = other;
		arc[Math.abs(this.type - 1)] = this.nodeId;

		ArcOp op = new ArcOp(OpsType.ADD, arc, System.currentTimeMillis());
		writeBus.store(op);
		arcops.add(op);
	}

	public void delNode(UUID other) {
		if (this.arcops == null) { // small performance gain
			update();
		}
		UUID[] arc = new UUID[2];
		arc[this.type] = other;
		arc[Math.abs(this.type - 1)] = this.nodeId;

		ArcOp op = new ArcOp(OpsType.DELETE, arc, System.currentTimeMillis());
		writeBus.store(op);
		arcops.add(op);
	}

	public void clear() {
		UUID[] nodes = update();
		arcops.ensureCapacity(arcops.size() + nodes.length);
		for (UUID other : nodes) {
			this.delNode(other);
		}
	}

	private UUID[] ops2nodes() {
		if (arcops == null)
			arcops = new ArrayList<ArcOp>(10);
		HashSet<UUID> nodeList = new HashSet<UUID>(arcops.size() / 2);
		for (ArcOp op : arcops) {
			switch (op.getType()) {
			case ADD:
				nodeList.add(op.get(this.type));
				break;
			case DELETE:
				nodeList.remove(op.get(this.type));
				break;
			}
		}
		if (arcops.size() > 0) {
			this.timestamp = arcops.get(arcops.size() - 1).getTimestamp_long();
		}
		return nodeList.toArray(new UUID[0]);
	}
}
<commit_msg>Ah, forgot to reenable a slight performance enhancement.<commit_after>package com.chap.memo.memoNodes.model;

import java.util.ArrayList;
import java.util.HashSet;

import com.chap.memo.memoNodes.MemoNode;
import com.chap.memo.memoNodes.bus.MemoReadBus;
import com.chap.memo.memoNodes.bus.MemoWriteBus;
import com.eaio.uuid.UUID;

public class ArcList {
	MemoReadBus readBus = MemoReadBus.getBus();
	MemoWriteBus writeBus = MemoWriteBus.getBus();
	long lastUpdate = 0;

	// UUID[] nodes = new UUID[0];
	ArrayList<ArcOp> arcops = null;

	int type; // 0: parent list, 1:child list
	UUID nodeId;

	private long timestamp;

	public ArcList(UUID nodeId, int type) {
		this.type = type;
		this.nodeId = nodeId;
	}

	public long getTimestamp_long() {
		return this.timestamp;
	}

	public UUID[] update() {
		if (this.arcops == null || readBus.opsChanged(lastUpdate)) {
			if (this.arcops == null) {
				this.arcops = readBus.getOps(nodeId, type, 0);
			} else {
				this.arcops.addAll(readBus.getOps(nodeId, type, lastUpdate));
			}
			lastUpdate = System.currentTimeMillis();
		}
		return ops2nodes();
	}

	public ArrayList<MemoNode> getNodes(long timestamp) {
		if (this.arcops == null) {
			this.arcops = readBus.getOps(nodeId, type, timestamp, 0);
		} else {
			this.arcops.addAll(readBus.getOps(nodeId, type, timestamp,
					lastUpdate));
		}
		UUID[] nodes = ops2nodes();
		ArrayList<MemoNode> result = new ArrayList<MemoNode>(nodes.length);
		for (UUID id : nodes) {
			result.add(readBus.find(id, timestamp));
		}
		return result;
	}

	public UUID[] getNodesIds() {
		return update();
	}

	public ArrayList<MemoNode> getNodes() {
		UUID[] nodes = update();
		ArrayList<MemoNode> result = new ArrayList<MemoNode>(nodes.length);
		for (UUID id : nodes) {
			result.add(new MemoNode(id));
		}
		return result;
	}

	public int getLength() {
		return update().length;
	}

	public void addNode(UUID other) {
		if (this.arcops == null) { // small performance gain
			update();
		}
		UUID[] arc = new UUID[2];
		arc[this.type] = other;
		arc[Math.abs(this.type - 1)] = this.nodeId;

		ArcOp op = new ArcOp(OpsType.ADD, arc, System.currentTimeMillis());
		writeBus.store(op);
		arcops.add(op);
	}

	public void delNode(UUID other) {
		if (this.arcops == null) { // small performance gain
			update();
		}
		UUID[] arc = new UUID[2];
		arc[this.type] = other;
		arc[Math.abs(this.type - 1)] = this.nodeId;

		ArcOp op = new ArcOp(OpsType.DELETE, arc, System.currentTimeMillis());
		writeBus.store(op);
		arcops.add(op);
	}

	public void clear() {
		UUID[] nodes = update();
		arcops.ensureCapacity(arcops.size() + nodes.length);
		for (UUID other : nodes) {
			this.delNode(other);
		}
	}

	private UUID[] ops2nodes() {
		if (arcops == null)
			arcops = new ArrayList<ArcOp>(10);
		HashSet<UUID> nodeList = new HashSet<UUID>(arcops.size() / 2);
		for (ArcOp op : arcops) {
			switch (op.getType()) {
			case ADD:
				nodeList.add(op.get(this.type));
				break;
			case DELETE:
				nodeList.remove(op.get(this.type));
				break;
			}
		}
		if (arcops.size() > 0) {
			this.timestamp = arcops.get(arcops.size() - 1).getTimestamp_long();
		}
		return nodeList.toArray(new UUID[0]);
	}
}

{'fraction_non_alphanumeric': 0.15221518987341773, 'fraction_numerical': 0.006012658227848101, 'mean_word_length': 3.696136701337296, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6193925', 'n_tokens_mistral': 2564, 'n_tokens_neox': 2339, 'n_words': 502}