# HG changeset patch # User Mario de Sousa # Date 1342627857 -3600 # Node ID d2122a32ec8694cbe2bb3aea70154e95168772f6 # Parent 06caf4782e514a474f3a08d42e100c98e2dbf55e Cleaning up the code. diff -r 06caf4782e51 -r d2122a32ec86 stage3/datatype_functions.cc --- a/stage3/datatype_functions.cc Wed Jul 18 17:04:34 2012 +0100 +++ b/stage3/datatype_functions.cc Wed Jul 18 17:10:57 2012 +0100 @@ -398,7 +398,7 @@ /* Search for a datatype inside a candidate_datatypes list. * Returns: position of datatype in the list, or -1 if not found. */ -int search_in_candidate_datatype_list(symbol_c *datatype, std::vector candidate_datatypes) { +int search_in_candidate_datatype_list(symbol_c *datatype, const std::vector &candidate_datatypes) { if (NULL == datatype) return -1; @@ -413,17 +413,12 @@ * Returns: If successful it returns true, false otherwise. */ bool remove_from_candidate_datatype_list(symbol_c *datatype, std::vector &candidate_datatypes) { - unsigned int ofs; - if (NULL == datatype) + int pos = search_in_candidate_datatype_list(datatype, candidate_datatypes); + if (pos < 0) return false; - for(ofs = 0; ofs < candidate_datatypes.size(); ofs++) - if (is_type_equal(datatype, candidate_datatypes[ofs])) - break; - if (ofs < candidate_datatypes.size()) { - candidate_datatypes.erase(candidate_datatypes.begin() + ofs); - return true; - } - return false; + + candidate_datatypes.erase(candidate_datatypes.begin() + pos); + return true; } diff -r 06caf4782e51 -r d2122a32ec86 stage3/datatype_functions.hh --- a/stage3/datatype_functions.hh Wed Jul 18 17:04:34 2012 +0100 +++ b/stage3/datatype_functions.hh Wed Jul 18 17:10:57 2012 +0100 @@ -142,7 +142,7 @@ /* Search for a datatype inside a candidate_datatypes list. * Returns: position of datatype in the list, or -1 if not found. */ -int search_in_candidate_datatype_list(symbol_c *datatype, std::vector candidate_datatypes); +int search_in_candidate_datatype_list(symbol_c *datatype, const std::vector &candidate_datatypes); /* Remove a datatype inside a candidate_datatypes list. * Returns: If successful it returns true, false otherwise.