Skip to content

Commit 2e74ea4

Browse files
committed
instanceof can be used here instead of isAssignableFrom
The right side is known at compile time. And it's even a tiny tiny tiny bit faster http://stackoverflow.com/questions/496928/what-is-the-difference-between-instanceof-and-class-isassignablefrom
1 parent e02b9ab commit 2e74ea4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bson/src/main/org/bson/codecs/DocumentCodec.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ private boolean skipField(final EncoderContext encoderContext, final String key)
166166
private void writeValue(final BsonWriter writer, final EncoderContext encoderContext, final Object value) {
167167
if (value == null) {
168168
writer.writeNull();
169-
} else if (Iterable.class.isAssignableFrom(value.getClass())) {
169+
} else if (value instanceof Iterable) {
170170
writeIterable(writer, (Iterable<Object>) value, encoderContext.getChildContext());
171-
} else if (Map.class.isAssignableFrom(value.getClass())) {
171+
} else if (value instanceof Map) {
172172
writeMap(writer, (Map<String, Object>) value, encoderContext.getChildContext());
173173
} else {
174174
Codec codec = registry.get(value.getClass());

0 commit comments

Comments
 (0)