Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Remove unnecessary branches in UrlDecoder#7272

Merged
davidsh merged 1 commit intodotnet:masterfrom
hughbe:patch-1
Mar 29, 2016
Merged

Remove unnecessary branches in UrlDecoder#7272
davidsh merged 1 commit intodotnet:masterfrom
hughbe:patch-1

Conversation

@hughbe
Copy link

@hughbe hughbe commented Mar 26, 2016

FlushBytes already checks for if _numBytes > 0 so we can remove this check at the call site

I renamed FlushBytes to FlushBytesIfNeeded to convey this semantic at the call site

/cc @stephentoub @jamesqo

@JonHanna
Copy link
Contributor

LGTM

@stephentoub
Copy link
Member

It's not necessarily a win, e.g. if it's common for the condition to be false and the callee doesn't get inlined. Do you have perf measurements for this showing impact one way or the other?

@stephentoub
Copy link
Member

cc: @davidsh

@hughbe
Copy link
Author

hughbe commented Mar 26, 2016

It's not necessarily a win

I don't have time tonight to do run perf measurements, but it may be more performant to keep the checks at the call site, and remove the check in the actual method implementation. Let me know what you think.

@hughbe
Copy link
Author

hughbe commented Mar 26, 2016

t it may be more performant to keep the checks at the call site, and remove the check in the actual method implementation.

This makes more sense and should be more performant. FIxed

@stephentoub
Copy link
Member

What's the motivation behind the change?

cc: @davidsh

@hughbe
Copy link
Author

hughbe commented Mar 27, 2016

None, just spotted some dead code

@stephentoub
Copy link
Member

I see. I'm ok with it if @davidsh is.

@@ -625,11 +625,8 @@ private struct UrlDecoder

private void FlushBytes()
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed the if (_numBytes > 0) because the caller already checks for it? If so, you should add an Assert() here to verify the condition.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@davidsh
Copy link
Contributor

davidsh commented Mar 29, 2016

Test Innerloop Ubuntu Release Build and Test
Test Innerloop OSX Release Build and Test
Test Innerloop OSX Debug Build and Test

@davidsh
Copy link
Contributor

davidsh commented Mar 29, 2016

LGTM

@davidsh davidsh merged commit 2d4dcfa into dotnet:master Mar 29, 2016
@hughbe hughbe deleted the patch-1 branch March 29, 2016 16:55
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Remove unnecessary branches in UrlDecoder

Commit migrated from dotnet/corefx@2d4dcfa
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants