Revision 9b96446a-2f1e-4c68-8d08-f9631c45b51d - Code Review Stack Exchange

Below is my method which I have wrote. Is there any possibility of optimizing few lines of code here? 

One of my colleague told me that you can use `streambuffer` for string and instead of using `string id` in the for loop you can declare outside?

I am not sure whether this will make any difference or not?

 void getRecord(uint64_t currentTime, const std::vector<uint32_t> &shards) {
 
 try {
 
 currentTime = (currentTime / 1000) * 1000;
 
 uint64_t start = (currentTime / (60 * 60 * 1000 * 24)) % 3;
 
 string query;
 Cassandra::Result result;
 
 std::string base(boost::lexical_cast<std::string>(currentTime) + ".");
 
 for (std::vector<uint32_t>::const_iterator it = shards.begin() ; it != shards.end(); ++it) {
 
 string id = base + boost::lexical_cast<std::string>(*it); // use stream buffer
 
 query = "select record_name, record_value from keyspace.hour_"+boost::lexical_cast<std::string>(start)+" where id ='"+id+"';";
 
 result = Cassandra::execute_query(query);
 
 }
 }
 
I am coming from Java background so not sure in C++ which one will be efficient as compared to other as C++ is all about memory allocation? Is there any way to optimize the above code slightly?

AltStyle によって変換されたページ (->オリジナル) /