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

Add additional checks to Vector class methods #1721

Merged
merged 2 commits into from
Jun 16, 2019

Conversation

mikee47
Copy link
Contributor

@mikee47 mikee47 commented Jun 12, 2019

#1618 (comment)

  • Change ensureCapacity to adjust new capacity by increment, thus simplifying code which uses it
  • Add bool return value to:
    addElement() - so that add() return value isn't meaningless
    ensureCapacity()
    setSize()
    insertElementAt()
    setElementAt()

* SmingHub#1618 (comment)
* Change `ensureCapacity` to adjust new capacity by `increment`, thus simplifying code which uses it
* Add `bool` return value to:
	`addElement()` - so that `add()` return value isn't meaningless
	`ensureCapacity()`
	`setSize()`
	`insertElementAt()`
	`setElementAt()`
@slaff slaff added this to the 3.9.0 milestone Jun 12, 2019
ensureCapacity(_capacity + _increment);
if (_size < _capacity)
_data[ _size++ ] = new Element(obj);
if (!ensureCapacity(_size + 1)) return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please at least put the return on the next line with a bit of offset ? Best would be to use curly braces.
Apply those changes to the other places where you have a return on the same line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be simplest to just fix all the coding style issues in this file, i.e. just apply the Sming CS and fix all the style issues. The Arduino Esp8266 doesn't use this class (uses std:;vector instead) so it's really a Sming-only file ATM.

@slaff slaff merged commit 7313c49 into SmingHub:develop Jun 16, 2019
@mikee47 mikee47 deleted the fix/Vector_class branch June 18, 2019 20:31
@slaff slaff removed the 3 - Review label Jul 26, 2019
mikee47 added a commit to mikee47/Sming that referenced this pull request Aug 1, 2019
mikee47 added a commit to mikee47/Sming that referenced this pull request Aug 1, 2019
For example,causes exception when sorting network list in `HttpServer_ConfigNetwork` sample
slaff pushed a commit that referenced this pull request Aug 1, 2019
For example,causes exception when sorting network list in `HttpServer_ConfigNetwork` sample
mikee47 added a commit to mikee47/Sming that referenced this pull request Aug 3, 2019
For example,causes exception when sorting network list in `HttpServer_ConfigNetwork` sample
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.

2 participants