Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated Encoding#replicate method #3741

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Compatibility:
* Add `Dir.for_fd` (#3681, @andrykonchin).
* Add `Dir.fchdir` (#3681, @andrykonchin).
* Add `Dir#chdir` (#3681, @andrykonchin).
* Remove deprecated `Encoding#replicate` method (#3681, @rwstauner).

Performance:

Expand Down
2 changes: 0 additions & 2 deletions spec/tags/core/encoding/replicate_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/tags/truffle/methods_tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/truffleruby/core/encoding/EncodingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
27 changes: 0 additions & 27 deletions src/main/java/org/truffleruby/core/encoding/EncodingNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
6 changes: 0 additions & 6 deletions src/main/ruby/truffleruby/core/encoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions src/main/ruby/truffleruby/core/truffle/encoding_operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading