Skip to content

Conversation

@hmel
Copy link
Contributor

@hmel hmel commented Jul 20, 2018

Use variable name instead of calling operator[] through &(*this)[0]

@promag
Copy link
Contributor

promag commented Jul 20, 2018

Actually it's not dependent of class layout, it uses operator[]:

const unsigned char& operator[](unsigned int pos) const { return vch[pos]; }

So I suggest to update the PR and commit.

Having said that, I like your change, but don't know if there is a motivation for the current code. Maybe @sipa has something to say?

@hmel
Copy link
Contributor Author

hmel commented Jul 20, 2018

You're absolutely right. I overlooked operator[], but I still think using variable name directly instead of &(*this)[0] going through operator[] to get the same thing. Maybe I'm missing something else? @sipa

@sipa
Copy link
Member

sipa commented Jul 20, 2018

Indeed, it is not dependent on class layout (no cast to char pointer is made), but the new code certainly looks better.

@promag
Copy link
Contributor

promag commented Jul 20, 2018

@hmel Please update PR and commit messages.

ACK the change.

@hmel hmel changed the title [Trivial] Use variable name instead of relying on class layout [Trivial] Use variable name instead of calling operator[] through *this Jul 20, 2018
@sipa
Copy link
Member

sipa commented Jul 20, 2018

utACK b0bb82209baceff2ae8ff566c374d1dd7725765e

@promag
Copy link
Contributor

promag commented Jul 20, 2018

Commit message still wrong.

@hmel
Copy link
Contributor Author

hmel commented Jul 21, 2018

Care to make a suggestion for commit message?

@promag
Copy link
Contributor

promag commented Jul 21, 2018

Sure, currently it's Use variable name instead of relying on class layout, how about trivial: Replace CPubKey::operator[] with CPubKey::vch where possible?

@fanquake fanquake changed the title [Trivial] Use variable name instead of calling operator[] through *this trivial: Replace CPubKey::operator[] with CPubKey::vch where possible Jul 21, 2018
@hmel hmel force-pushed the use_varname_not_this branch from b0bb822 to 6755569 Compare July 21, 2018 08:11
@l2a5b1
Copy link
Contributor

l2a5b1 commented Jul 21, 2018

Nice improvement, utACK 6755569

@promag
Copy link
Contributor

promag commented Jul 21, 2018

utACK 6755569.

@fanquake
Copy link
Member

utACK 6755569

@maflcko maflcko merged commit 6755569 into bitcoin:master Jul 22, 2018
maflcko pushed a commit that referenced this pull request Jul 22, 2018
…where possible

6755569 trivial: Replace CPubKey::operator[] with CPubKey::vch where possible (Nikolay Mitev)

Pull request description:

  Use variable name instead of calling operator[] through &(*this)[0]

Tree-SHA512: 7054ffda0fa33fb45d4d9f3b29698643f02fd1421d78d5197a0881f2c368dc410647fd2e1a6feb8048e30f8ab8bc2fa8749bf42b9ccbe42c30de8ff80ac45274
@laanwj
Copy link
Member

laanwj commented Jul 22, 2018

Post=merge ACK, nice cleanup

@hmel hmel deleted the use_varname_not_this branch July 22, 2018 13:34
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 25, 2019
…where possible

Summary:
6755569 trivial: Replace CPubKey::operator[] with CPubKey::vch where possible (Nikolay Mitev)

Pull request description:

  Use variable name instead of calling operator[] through &(*this)[0]

Tree-SHA512: 7054ffda0fa33fb45d4d9f3b29698643f02fd1421d78d5197a0881f2c368dc410647fd2e1a6feb8048e30f8ab8bc2fa8749bf42b9ccbe42c30de8ff80ac45274

Backport of Core PR13722
bitcoin/bitcoin#13722

Test Plan:
  make check

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D4248
jonspock pushed a commit to jonspock/devault that referenced this pull request Dec 27, 2019
…where possible

Summary:
6755569840 trivial: Replace CPubKey::operator[] with CPubKey::vch where possible (Nikolay Mitev)

Pull request description:

  Use variable name instead of calling operator[] through &(*this)[0]

Tree-SHA512: 7054ffda0fa33fb45d4d9f3b29698643f02fd1421d78d5197a0881f2c368dc410647fd2e1a6feb8048e30f8ab8bc2fa8749bf42b9ccbe42c30de8ff80ac45274

Backport of Core PR13722
bitcoin/bitcoin#13722

Test Plan:
  make check

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D4248
jonspock pushed a commit to devaultcrypto/devault that referenced this pull request Dec 29, 2019
…where possible

Summary:
6755569840 trivial: Replace CPubKey::operator[] with CPubKey::vch where possible (Nikolay Mitev)

Pull request description:

  Use variable name instead of calling operator[] through &(*this)[0]

Tree-SHA512: 7054ffda0fa33fb45d4d9f3b29698643f02fd1421d78d5197a0881f2c368dc410647fd2e1a6feb8048e30f8ab8bc2fa8749bf42b9ccbe42c30de8ff80ac45274

Backport of Core PR13722
bitcoin/bitcoin#13722

Test Plan:
  make check

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D4248
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 29, 2020
…y::vch where possible

6755569 trivial: Replace CPubKey::operator[] with CPubKey::vch where possible (Nikolay Mitev)

Pull request description:

  Use variable name instead of calling operator[] through &(*this)[0]

Tree-SHA512: 7054ffda0fa33fb45d4d9f3b29698643f02fd1421d78d5197a0881f2c368dc410647fd2e1a6feb8048e30f8ab8bc2fa8749bf42b9ccbe42c30de8ff80ac45274
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
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