-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
get IOError down to 24 bytes (#1355) #1376
Conversation
Can one of the admins verify this patch? |
9 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Hmm, I wonder where the enum discriminator went in the “good” case. The only excuse for shrinking this by one byte when |
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.
Sadly, I don’t think this change is quite right: StaticString
and String
are different types, which means this has changed the public API surface of the module in a backward-incompatible way (i.e. it is possible that some code used to compile and now does not).
Sadly that particular change is not available to us: we’ll need to find another approach here.
First of all, thanks very much for this PR @realdoug ! As @Lukasa points out this is public API breaking right now. That's my mistake, I didn't quite appreciate how much we exported in our API here but I have a proposal how we can fix it all and remain API stable: Internally we just stop using the enum case that uses the
to
we should then also deprecate this
and rewrite it as
|
Gotcha. I figured you may want to paper over it somehow. Pushed a new version w/ updates @Lukasa @weissi ; It's worth noting that this implementation loses the information distinguishing between reason/function. Perhaps that's ok, though if so, the enum & the computed property that returns it should be deprecated as well, right?
Edit: realized this isn't possible since String -> StatcString conversion is impossible. |
Also, the deprecation causes many tests to emit warnings, which need to be cleaned up, but I wanted to validate the approach first. |
@realdoug nice once! Great job! The information loss is okay, the old one was just there because in Swift before 5.0, Strings were very bad so StaticString made sense. Regarding the warnings, can’t we just make NIO use We might want to add one single test which tests that the old |
@swift-nio-bot test this please |
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.
Thanks so much! I’m happy with this , we just need to adjust the copyright years and then I think this is good to go
CI passed, that failure is a spurious perf test. So it’s all good from my PoV apart from the copyright years |
ah my bad @weissi copyright year is fixed now. |
@swift-nio-bot test this please |
@swift-nio-bot test this please |
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.
Thanks so much! This looks great
@swift-nio-bot test this please |
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.
This looks great, thanks so much @realdoug!
@swift-nio-bot test this please |
1 similar comment
@swift-nio-bot test this please |
Awesome! |
resolves #1355 shaving off 2 bytes from
IOError
structModifications:
This one had a bit of a curveball. Replacing
StaticString
shaves off one byte. The other extra byte is saved by switching the order that theenum
andInt32
properties are declared. Seems like a compiler bug to me.For example:
I'm curious now why that might be.
Result:
New condition:
print(MemoryLayout<IOError>.size) // 24