Skip to content

Commit 539114c

Browse files
committed
Some tweaks from feedback
1 parent 2959d90 commit 539114c

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

driver/src/main/java/org/neo4j/driver/internal/InternalRecord.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,13 @@
3838
public class InternalRecord extends InternalRecordAccessor implements Record
3939
{
4040
private final List<String> keys;
41-
private final Map<String, Integer> keyIndexLookup;
4241
private final Value[] values;
4342
private int hashcode = 0;
4443

4544
public InternalRecord( List<String> keys, Value[] values )
4645
{
4746
this.keys = keys;
4847
this.values = values;
49-
50-
int numFields = keys.size();
51-
Map<String, Integer> fieldLookup = new HashMap<>( numFields );
52-
for ( int i = 0; i < numFields; i++ )
53-
{
54-
String name = keys.get(i);
55-
fieldLookup.put( name, i );
56-
}
57-
this.keyIndexLookup = fieldLookup;
5848
}
5949

6050
@Override
@@ -66,8 +56,8 @@ public List<String> keys()
6656
@Override
6757
public int index( String key )
6858
{
69-
Integer result = keyIndexLookup.get( key );
70-
if ( result == null )
59+
int result = keys.indexOf( key );
60+
if ( result == -1 )
7161
{
7262
throw new NoSuchElementException( "Unknown key: " + key );
7363
}
@@ -80,15 +70,15 @@ public int index( String key )
8070
@Override
8171
public boolean containsKey( String key )
8272
{
83-
return keyIndexLookup.containsKey( key );
73+
return keys.contains( key );
8474
}
8575

8676
@Override
8777
public Value get( String key )
8878
{
89-
Integer fieldIndex = keyIndexLookup.get( key );
79+
int fieldIndex = keys.indexOf( key );
9080

91-
if ( fieldIndex == null )
81+
if ( fieldIndex == -1 )
9282
{
9383
return Values.NULL;
9484
}

driver/src/main/java/org/neo4j/driver/internal/InternalResultCursor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private StreamCollector newRunResponseCollector()
8282
@Override
8383
public void keys( String[] names )
8484
{
85-
keys = new ArrayList<>( Arrays.asList( names ) );
85+
keys = Arrays.asList( names );
8686
}
8787

8888
@Override

0 commit comments

Comments
 (0)