Skip to content

Commit ec7ec41

Browse files
author
Alex Soto
committed
adds fail-fast approach.
1 parent 20aa93a commit ec7ec41

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/main/java/com/github/fge/jsonpatch/JacksonUtils.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,19 @@ public final static String getLast(JsonPointer jsonPointer)
7575
{
7676
String representation = jsonPointer.toString();
7777

78-
if(representation != null)
78+
if(representation == null) return "";
79+
80+
int slashPosition = -1;
81+
if((slashPosition = representation.lastIndexOf('/')) != -1)
7982
{
80-
int slashPosition = -1;
81-
if((slashPosition = representation.lastIndexOf('/')) != -1)
82-
{
83-
return representation.substring(slashPosition+1);
84-
}
85-
else
86-
{
87-
return representation;
88-
}
83+
return representation.substring(slashPosition+1);
8984
}
85+
else
86+
{
87+
return representation;
88+
}
89+
9090

91-
return "";
9291
}
9392

9493
public final static JsonPointer empty()

0 commit comments

Comments
 (0)