diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ebfc3f1e4ad..7abe680d689f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ Compatibility: * Declare `File::SHARE_DELETE` constant (#3745, @andrykonchin). * Support `symbolize_names` argument to `MatchData#named_captures` (#3681, @rwstauner). * Support `Proc#initialize_{dup,copy}` for subclasses (#3681, @rwstauner). +* Remove deprecated `Encoding#replicate` method (#3681, @rwstauner). Performance: diff --git a/spec/tags/core/encoding/replicate_tags.txt b/spec/tags/core/encoding/replicate_tags.txt deleted file mode 100644 index 204f9a955f6f..000000000000 --- a/spec/tags/core/encoding/replicate_tags.txt +++ /dev/null @@ -1,2 +0,0 @@ -slow:Encoding#replicate raises EncodingError if too many encodings -fails:Encoding#replicate has been removed diff --git a/spec/tags/truffle/methods_tags.txt b/spec/tags/truffle/methods_tags.txt index d29266188948..dc62e547dd47 100644 --- a/spec/tags/truffle/methods_tags.txt +++ b/spec/tags/truffle/methods_tags.txt @@ -101,7 +101,6 @@ fails(we defined these methods on the generated Data subclasses):Public methods fails(we defined these methods on the generated Data subclasses):Public methods on Data should include to_s fails(we defined these methods on the generated Data subclasses):Public methods on Data should include with fails:Public methods on Dir should include chdir -fails:Public methods on Encoding should not include replicate fails:Public methods on Fiber should include kill fails:Public methods on Method should include dup fails:Public methods on Module should include set_temporary_name diff --git a/src/main/java/org/truffleruby/core/encoding/EncodingManager.java b/src/main/java/org/truffleruby/core/encoding/EncodingManager.java index ae23a030a0ec..3eb5fcdfe40e 100644 --- a/src/main/java/org/truffleruby/core/encoding/EncodingManager.java +++ b/src/main/java/org/truffleruby/core/encoding/EncodingManager.java @@ -256,16 +256,6 @@ public synchronized RubyEncoding createDummyEncoding(String name) { return defineDynamicEncoding(Encodings.DUMMY_ENCODING_BASE, nameBytes); } - @TruffleBoundary - public synchronized RubyEncoding replicateEncoding(RubyEncoding encoding, String name) { - if (getRubyEncoding(name) != null) { - return null; - } - - final byte[] nameBytes = StringOperations.encodeAsciiBytes(name); - return defineDynamicEncoding(encoding.jcoding, nameBytes); - } - public RubyEncoding getLocaleEncoding() { return localeEncoding; } diff --git a/src/main/java/org/truffleruby/core/encoding/EncodingNodes.java b/src/main/java/org/truffleruby/core/encoding/EncodingNodes.java index 472f2af3c78d..2a2afa4e85c8 100644 --- a/src/main/java/org/truffleruby/core/encoding/EncodingNodes.java +++ b/src/main/java/org/truffleruby/core/encoding/EncodingNodes.java @@ -537,33 +537,6 @@ public static RubyArray setIndexOrRaiseError(Node node, String name, RubyEncodin } - @Primitive(name = "encoding_replicate") - public abstract static class EncodingReplicateNode extends EncodingCreationNode { - - @Specialization(guards = "strings.isRubyString(this, nameObject)", limit = "1") - static RubyArray encodingReplicate(RubyEncoding object, Object nameObject, - @Cached RubyStringLibrary strings, - @Cached ToJavaStringNode toJavaStringNode, - @Bind("this") Node node) { - final String name = toJavaStringNode.execute(node, nameObject); - - final RubyEncoding newEncoding = replicate(node, name, object); - return setIndexOrRaiseError(node, name, newEncoding); - } - - @TruffleBoundary - private static RubyEncoding replicate(Node node, String name, RubyEncoding encoding) { - if (getContext(node).getEncodingManager().getNumberOfEncodings() >= Encodings.MAX_NUMBER_OF_ENCODINGS) { - throw new RaiseException( - getContext(node), - coreExceptions(node).encodingErrorTooManyEncodings(Encodings.MAX_NUMBER_OF_ENCODINGS, node)); - } - - return getContext(node).getEncodingManager().replicateEncoding(encoding, name); - } - - } - @Primitive(name = "encoding_create_dummy") public abstract static class DummyEncodingNode extends EncodingCreationNode { diff --git a/src/main/ruby/truffleruby/core/encoding.rb b/src/main/ruby/truffleruby/core/encoding.rb index aba9d2968861..3415f66b2196 100644 --- a/src/main/ruby/truffleruby/core/encoding.rb +++ b/src/main/ruby/truffleruby/core/encoding.rb @@ -138,12 +138,6 @@ def names names end - def replicate(name) - warn 'Encoding#replicate is deprecated and will be removed in Ruby 3.3; use the original encoding instead', category: :deprecated, uplevel: 1 - - Truffle::EncodingOperations.replicate_encoding(self, name) - end - def _dump(depth) name end diff --git a/src/main/ruby/truffleruby/core/truffle/encoding_operations.rb b/src/main/ruby/truffleruby/core/truffle/encoding_operations.rb index 2a231705a262..27f6bce35ab6 100644 --- a/src/main/ruby/truffleruby/core/truffle/encoding_operations.rb +++ b/src/main/ruby/truffleruby/core/truffle/encoding_operations.rb @@ -49,13 +49,6 @@ def self.dummy_encoding(name) [new_encoding, index] end - def self.replicate_encoding(encoding, name) - name = StringValue(name) - new_encoding, _index = Primitive.encoding_replicate encoding, name - EncodingMap[name.upcase.to_sym] = [nil, new_encoding] - new_encoding - end - def self.define_alias(encoding, alias_name) key = alias_name.upcase.to_sym EncodingMap[key] = [alias_name, encoding]