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 30, 2024
1 parent 377e27a commit 3f64852
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 3f64852

Please sign in to comment.