Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

Refactored the Function<T,Integer> to ToIntFunction<T>. #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.function.ToIntFunction;

/**
*
Expand Down Expand Up @@ -167,7 +167,7 @@ private void writeNode(DataWriter out, Node<T> node) throws IOException {
Map<String, Integer> localMap = new LinkedHashMap<>();
Map<String, Integer> commonMap = StringTable.commonStrings(revision.major()).inverse();

Function<String, Integer> addStringOffset = typeName -> {
ToIntFunction<String> addStringOffset = typeName -> {
if (commonMap.containsKey(typeName)) {
return commonMap.get(typeName);
} else if (localMap.containsKey(typeName)) {
Expand All @@ -181,8 +181,8 @@ private void writeNode(DataWriter out, Node<T> node) throws IOException {

// apply string offsets
types.forEach(type -> {
type.typeOffset(addStringOffset.apply(type.typeName()));
type.nameOffset(addStringOffset.apply(type.fieldName()));
type.typeOffset(addStringOffset.applyAsInt(type.typeName()));
type.nameOffset(addStringOffset.applyAsInt(type.fieldName()));
});

out.writeInt(types.size());
Expand Down