Skip to content

Commit

Permalink
Simplify string creation
Browse files Browse the repository at this point in the history
Using a different String constructor avoids needing an inner lookup, and avoids having to catch an exception.
  • Loading branch information
drewnoakes committed Nov 21, 2023
1 parent 62d0be5 commit 33fbda2
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions Source/com/drew/metadata/StringValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.drew.lang.annotations.NotNull;
import com.drew.lang.annotations.Nullable;

import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

/**
Expand Down Expand Up @@ -64,11 +63,7 @@ public String toString()
public String toString(@Nullable Charset charset)
{
if (charset != null) {
try {
return new String(_bytes, charset.name());
} catch (UnsupportedEncodingException ex) {
// fall through
}
return new String(_bytes, charset);
}

return new String(_bytes);
Expand Down

0 comments on commit 33fbda2

Please sign in to comment.