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

Tiny code simplification in codec #54

Merged
1 commit merged into from Sep 14, 2018
Merged

Tiny code simplification in codec #54

1 commit merged into from Sep 14, 2018

Conversation

ferhatelmas
Copy link
Contributor

Drop unnecessary slice since type is already a slice.

@coveralls
Copy link

coveralls commented Sep 11, 2018

Pull Request Test Coverage Report for Build 150

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 99.14%

Totals Coverage Status
Change from base Build 149: 0.0%
Covered Lines: 346
Relevant Lines: 349

💛 - Coveralls

2 similar comments
@coveralls
Copy link

Pull Request Test Coverage Report for Build 150

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 99.14%

Totals Coverage Status
Change from base Build 149: 0.0%
Covered Lines: 346
Relevant Lines: 349

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 150

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 99.14%

Totals Coverage Status
Change from base Build 149: 0.0%
Covered Lines: 346
Relevant Lines: 349

💛 - Coveralls

@@ -125,7 +125,7 @@ func (u *UUID) decodeCanonical(t []byte) error {
return fmt.Errorf("uuid: incorrect UUID format %s", t)
}

src := t[:]
Copy link
Member

Choose a reason for hiding this comment

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

Could this be an optimization? I recall a talk from today talking about "this being on the stack" now IIRC.

Can we benchmark before and after?

Copy link
Member

Choose a reason for hiding this comment

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

Both are values on stack I presume

Copy link
Member

Choose a reason for hiding this comment

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

The t value is already a slice i think. The [:] should be a no-op.

Copy link
Member

Choose a reason for hiding this comment

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

It looks like a no-op indeed https://go.godbolt.org/z/OuMHTy

Copy link
Member

Choose a reason for hiding this comment

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

What's the reason for even doing it? Might it make more sense just to put src in the function declaration and omit the line altogether? It's not a breaking API change.

Copy link
Member

Choose a reason for hiding this comment

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

@theckman Unfortunately, that would mean we lose consistency with the rest of the decodeX methods in that file, which all take a t []byte parameter.

FWIW, I have no opinion on this. I think the proposed change is fine as-is.

@ghost ghost merged commit 47cd1dc into gofrs:master Sep 14, 2018
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants