Skip to content

Commit d5e3cb4

Browse files
committed
[refactor] set ByteList for buffer - do not create string
1 parent e13a281 commit d5e3cb4

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/main/java/org/jruby/ext/openssl/Cipher.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,6 @@ else if ( "RC4".equalsIgnoreCase(cryptoBase) ) {
10911091
}
10921092
cipherInited = true;
10931093
processedDataBytes = 0;
1094-
//outBuffer = new ByteList(keyLength);
10951094
}
10961095

10971096
private String getCipherAlgorithm() {
@@ -1100,7 +1099,6 @@ private String getCipherAlgorithm() {
11001099
}
11011100

11021101
private int processedDataBytes = 0;
1103-
//private volatile ByteList outBuffer;
11041102
private byte[] lastIV;
11051103

11061104
@JRubyMethod
@@ -1150,12 +1148,11 @@ public IRubyObject update(final ThreadContext context, final IRubyObject arg, IR
11501148
throw newCipherError(runtime, e);
11511149
}
11521150

1153-
if( buffer == null ) {
1154-
return RubyString.newString(runtime, str);
1155-
} else {
1156-
buffer = TypeConverter.convertToType(buffer, context.runtime.getString(), "to_str", true);
1157-
return ((RubyString) buffer).replace(RubyString.newString(runtime, str));
1158-
}
1151+
if ( buffer == null ) return RubyString.newString(runtime, str);
1152+
1153+
buffer = TypeConverter.convertToType(buffer, context.runtime.getString(), "to_str", true);
1154+
((RubyString) buffer).setValue(str);
1155+
return buffer;
11591156
}
11601157

11611158
@JRubyMethod(name = "<<")

0 commit comments

Comments
 (0)