-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement String#undump in C extension library #1
Conversation
this is just a implementation limitation
@@ -6,21 +6,21 @@ See [Feature #12275](https://bugs.ruby-lang.org/issues/12275) for details. | |||
## Usage | |||
|
|||
```ruby | |||
require 'string-undump' | |||
require 'string_undump' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the name of this library is renamed from string-undump
(hyphen) to string_undump
(underscore) due to naming convention of C extension.
s.gsub!(/(?:\\x#{hex}{2})+/) {|m| | ||
m.gsub(/\\x/, '').scan(/../).map(&:hex).pack("C*").force_encoding(e) | ||
} | ||
s | ||
end | ||
|
||
alias_method(:undump, :undump_badly) unless self.new.respond_to?(:undump) | ||
alias_method(:undump, :undump_roughly) unless self.new.respond_to?(:undump) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ruby implementation remains as String#undump_badly
.
Add
String#undump_roughly
, a C extension implementation ofString#undump
.Now
undump
with Ruby trunk is over 9 times faster thaneval
🎉