`const std::string` as a return type does not make sense. Each call to this 
method will allocate a new `std::string` you are then saying it must not be 
changed so the caller must allocate a new `std::string` to mutate or will 
accidentally do so if they don't remember to add const or use `auto&&`.

```
# results 1-2 string allocation.
auto&& type = object.getType();

# results in 2-3 string allocations.
auto type = object.getType();

# results in 2-3 allocations.
std::string type = object.getType();

std::unordered_map<std::string, int32_t> map;
# results in 2-3 allocations of std::string.
map.emplace(object.getType(), someInt);
```


[ Full content available at: https://github.com/apache/geode-native/pull/339 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to