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

[] and = operator always new memory? setInt setString will save much memory? #21

Closed
cnsoft opened this issue Jun 3, 2014 · 1 comment
Assignees

Comments

@cnsoft
Copy link

cnsoft commented Jun 3, 2014

e.g:
val["positionx"] = 10;
val["positionx"].setInt(10);

is there some different with the two different function call?

@madbranch
Copy link
Contributor

The operator= for the class Value has only been defined as

Value &operator=(const Value &src);

So when you write:

val["positionx"] = 10;

A Value instance is implicitly created using the following constructor:

Value(int newInt);

So in your example, the call to setInt(10) is probably much faster than using the operator=

To improve the operator=, I will overload the operator= to accept the same types as the constructors.

@madbranch madbranch self-assigned this Feb 9, 2015
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

No branches or pull requests

2 participants