Skip to content

Commit

Permalink
[refactor] simplify - extra checks not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
kares committed Oct 16, 2024
1 parent 54b8fb1 commit 0b9ff7d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/org/jruby/ext/openssl/PKeyEC.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a
final RubyString str = readInitArg(context, arg);
final String strJava = str.toString();

if (!strJava.isEmpty() && isCurveName(strJava)) {
if (isCurveName(strJava)) {
this.curveName = strJava;
return this;
}
Expand Down Expand Up @@ -349,8 +349,9 @@ else if ( key instanceof ECPublicKey ) {
private void setCurveNameFromPublicKeyIfNeeded() {
if (curveName == null && publicKey != null) {
final String oid = getCurveNameObjectIdFromKey(getRuntime(), publicKey);
if (isCurveName(oid)) {
this.curveName = getCurveName(new ASN1ObjectIdentifier(oid));
final Optional<ASN1ObjectIdentifier> curveId = getCurveOID(oid);
if (curveId.isPresent()) {
this.curveName = getCurveName(curveId.get());
}
}
}
Expand Down

0 comments on commit 0b9ff7d

Please sign in to comment.