GEODE-3288: Converts char* to std::string on public API.#160
Conversation
9658b9f to
edf10d0
Compare
| } | ||
|
|
||
| string locatorArgs = LocatorStartArgs + " --name=" + serverName + startDir + extraLocatorArgs; | ||
| string locatorArgs = LocatorStartArgs + " --name=" + serverName + startDir + extraLocatorArgs + " --http-service-port=0"; |
There was a problem hiding this comment.
This change shaves about 10s off each test!
| ) | ||
|
|
||
| include(PrecompiledHeader) | ||
| add_precompiled_header(${PROJECT_NAME} geode_includes.hpp FORCEINCLUDE) |
There was a problem hiding this comment.
Added precompiled headers to work around and speed up issue including marshal_as headers.
dgkimura
left a comment
There was a problem hiding this comment.
Looks good. Just small comments so feel free to ignore as you see fit. I did notice you changed many types to universal refs auto&&, which I assume was intentional. How did you decide on using auto& vs const auto& vs auto&&?
| string(REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||
| string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /clr /wd4947 /wd4251 /wd4635 /doc /we4488") | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /clr /bigobj /wd4947 /wd4251 /wd4635 /doc /we4488") |
There was a problem hiding this comment.
I'm a little worried about remembering the context of these flags and why they're required.
There was a problem hiding this comment.
Good point, though if we remove it the project won't link, so context will be re-established. ;) Would you like a comment?
There was a problem hiding this comment.
I would find a comment to be helpful
| */ | ||
| void setEndpoints(char* endpoints); | ||
| void setEndpoints(const std::string& endpoints); | ||
| void setEndpoints(std::string&& endpoints); |
There was a problem hiding this comment.
Did you implement an rvalue ref version of this function? If so, why was it needed?
There was a problem hiding this comment.
I think I was experimenting here. I should back it out. We can always add it later.
void setEndpoints(const std::string& endpoints);
Does not result in a copy to make the call but since internally we keep it a copy is made. No optimization can be made but none is really necessary unless the param is an r-value. The method also fails to communicate that we are keeping a copy.
void setEndpoints(std::string endpoints);
Communicates we are keeping a copy as copy is don't on the call. Unoptimized the copy happens also at the assignment to the member variable, though most modern compilers I believe will optimize that second copy out.
void setEndpoints(std::string&& endpoints);
Communicates a copy is kept and optimizes the r-value to avoid extra copies.
The two methods implemented are consistent with what the container class templates generate to handle l-values and r-values optimally.
|
|
||
| /** Template CacheableKey class for primitive types. */ | ||
| template <typename TObj, int8_t TYPEID, const char* TYPENAME, | ||
| const char* SPRINTFSYM, int32_t STRSIZE> |
There was a problem hiding this comment.
Do we want to change these template arguments from char* to std::string as well?
There was a problem hiding this comment.
I don't think we can, std::string is not constexpr. C++17 adds std::string_view which is constexpr.
| @@ -219,8 +219,9 @@ void QueryHelper::populatePortfolioPdxData(std::shared_ptr<Region>& rptr, | |||
| auto keyport = CacheableKey::create(portname); | |||
|
|
|||
| rptr->put(keyport, port); | |||
| LOGINFO("populatePortfolioPdxData:: Put for iteration current = %d done", | |||
| current); | |||
| // LOGINFO("populatePortfolioPdxData:: Put for iteration current = %d | |||
There was a problem hiding this comment.
Yes, it fills the logs. I should probably just delete but for diagnostics someone may want it.
There was a problem hiding this comment.
Maybe LOGDEBUG is a good compromise?
| bool pisLargeResultset = false) { | ||
| size_t querylen = static_cast<int>(strlen(pquery)); | ||
| if (querylen < MAX_QRY_LENGTH) memcpy(_query, pquery, querylen); | ||
| memset(&_query[querylen], '\0', 1); |
There was a problem hiding this comment.
Yay! Glad to see these converted.
| @@ -298,32 +305,6 @@ CacheableString::~CacheableString() { | |||
| } | |||
| } | |||
|
|
|||
| int32_t CacheableString::logString(char* buffer, int32_t maxLength) const { | |||
| if (bucketId == -1) { | ||
| return; | ||
| } | ||
| auto&& partition = fpResolver->getPartitionName(event); |
There was a problem hiding this comment.
Same comment as above about intent of universal refs here.
| return names[ordinal]; | ||
| } | ||
|
|
||
| return names[NONE]; |
There was a problem hiding this comment.
Ugh.. I realize you didn't introduce this, but I'm not really a fan of using enum types as integers in c++.
There was a problem hiding this comment.
I agree. Can you open a ticket and we can investigate alternatives?
There was a problem hiding this comment.
Created ticket here: https://issues.apache.org/jira/browse/GEODE-4032
| if (INVALIDATE <= ordinal && ordinal <= LOCAL_DESTROY) { | ||
| return names[ordinal]; | ||
| } | ||
| return nullptr; | ||
| return names[INVALID_ACTION]; |
There was a problem hiding this comment.
Same as other comment regarding enums
| } | ||
| } | ||
|
|
||
| cacheImpl->getPoolManager().addPool(name, | ||
| cacheImpl->getPoolManager().addPool(std::move(name), |
There was a problem hiding this comment.
Why not? The method is PoolFactory::create(std::string name) so I am moving the already copied value into the member variable, rather than another copy. Saves the copy of the underlying char[].
There was a problem hiding this comment.
I feel like it makes it just a little easier to shoot ourselves in the foot (e.g. accidentally editing to use name after this line). Also since PoolFactory::create probably won't be called in a tight loop a copy doesn't seem too terrible?
|
@dgkimura Can I get a final blessing? |
Excludes DataInput/Output, Serializer and CacheableString.
689f8de to
3e3f26f
Compare
- Reduces integration test runtimes by not starting http service in locators. - Fixes some const method declarations.
- Reduces integration test runtimes by not starting http service in locators. - Fixes some const method declarations.
- Reduces integration test runtimes by not starting http service in locators. - Fixes some const method declarations.
Excludes DataInput/Output, Serializer and CacheableString.