Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Side by Side Diff: base/tracked_objects.cc

Issue 155022: Fix few trivial Coverity issues, mainly PASS_BY_VALUE. (Closed)
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/tracked_objects.h ('k') | net/base/x509_certificate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/tracked_objects.h" 5 #include "base/tracked_objects.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 758
759 default: 759 default:
760 break; 760 break;
761 } 761 }
762 } 762 }
763 if (tiebreaker_ && !use_tiebreaker_for_sort_only_) 763 if (tiebreaker_ && !use_tiebreaker_for_sort_only_)
764 return tiebreaker_->Acceptable(sample); 764 return tiebreaker_->Acceptable(sample);
765 return true; 765 return true;
766 } 766 }
767 767
768 void Comparator::SetTiebreaker(Selector selector, const std::string required) { 768 void Comparator::SetTiebreaker(Selector selector, const std::string& required) {
769 if (selector == selector_ || NIL == selector) 769 if (selector == selector_ || NIL == selector)
770 return; 770 return;
771 combined_selectors_ |= selector; 771 combined_selectors_ |= selector;
772 if (NIL == selector_) { 772 if (NIL == selector_) {
773 selector_ = selector; 773 selector_ = selector;
774 if (required.size()) 774 if (required.size())
775 required_ = required; 775 required_ = required;
776 return; 776 return;
777 } 777 }
778 if (tiebreaker_) { 778 if (tiebreaker_) {
(...skipping 18 matching lines...) Expand all
797 return; 797 return;
798 if (!tiebreaker_) { 798 if (!tiebreaker_) {
799 use_tiebreaker_for_sort_only_ = true; 799 use_tiebreaker_for_sort_only_ = true;
800 tiebreaker_ = new Comparator; 800 tiebreaker_ = new Comparator;
801 tiebreaker_->SetTiebreaker(selector, ""); 801 tiebreaker_->SetTiebreaker(selector, "");
802 } else { 802 } else {
803 tiebreaker_->SetSubgroupTiebreaker(selector); 803 tiebreaker_->SetSubgroupTiebreaker(selector);
804 } 804 }
805 } 805 }
806 806
807 void Comparator::ParseKeyphrase(const std::string key_phrase) { 807 void Comparator::ParseKeyphrase(const std::string& key_phrase) {
808 static std::map<const std::string, Selector> key_map; 808 static std::map<const std::string, Selector> key_map;
809 static bool initialized = false; 809 static bool initialized = false;
810 if (!initialized) { 810 if (!initialized) {
811 initialized = true; 811 initialized = true;
812 key_map["count"] = COUNT; 812 key_map["count"] = COUNT;
813 key_map["duration"] = AVERAGE_DURATION; 813 key_map["duration"] = AVERAGE_DURATION;
814 key_map["birth"] = BIRTH_THREAD; 814 key_map["birth"] = BIRTH_THREAD;
815 key_map["death"] = DEATH_THREAD; 815 key_map["death"] = DEATH_THREAD;
816 key_map["file"] = BIRTH_FILE; 816 key_map["file"] = BIRTH_FILE;
817 key_map["function"] = BIRTH_FUNCTION; 817 key_map["function"] = BIRTH_FUNCTION;
818 key_map["line"] = BIRTH_LINE; 818 key_map["line"] = BIRTH_LINE;
819 } 819 }
820 820
821 std::string required; 821 std::string required;
822 size_t equal_offset = key_phrase.find('=', 0); 822 size_t equal_offset = key_phrase.find('=', 0);
823 if (key_phrase.npos != equal_offset) 823 if (key_phrase.npos != equal_offset)
824 required = key_phrase.substr(equal_offset + 1, key_phrase.npos); 824 required = key_phrase.substr(equal_offset + 1, key_phrase.npos);
825 std::string keyword(key_phrase.substr(0, equal_offset)); 825 std::string keyword(key_phrase.substr(0, equal_offset));
826 keyword = StringToLowerASCII(keyword); 826 keyword = StringToLowerASCII(keyword);
827 if (key_map.end() == key_map.find(keyword)) 827 if (key_map.end() == key_map.find(keyword))
828 return; 828 return;
829 SetTiebreaker(key_map[keyword], required); 829 SetTiebreaker(key_map[keyword], required);
830 } 830 }
831 831
832 bool Comparator::ParseQuery(const std::string query) { 832 bool Comparator::ParseQuery(const std::string& query) {
833 for (size_t i = 0; i < query.size();) { 833 for (size_t i = 0; i < query.size();) {
834 size_t slash_offset = query.find('/', i); 834 size_t slash_offset = query.find('/', i);
835 ParseKeyphrase(query.substr(i, slash_offset - i)); 835 ParseKeyphrase(query.substr(i, slash_offset - i));
836 if (query.npos == slash_offset) 836 if (query.npos == slash_offset)
837 break; 837 break;
838 i = slash_offset + 1; 838 i = slash_offset + 1;
839 } 839 }
840 840
841 // Select subgroup ordering (if we want to display the subgroup) 841 // Select subgroup ordering (if we want to display the subgroup)
842 SetSubgroupTiebreaker(COUNT); 842 SetSubgroupTiebreaker(COUNT);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 (combined_selectors_ & BIRTH_THREAD) ? "*" : 898 (combined_selectors_ & BIRTH_THREAD) ? "*" :
899 sample.birth().birth_thread()->ThreadName().c_str(), 899 sample.birth().birth_thread()->ThreadName().c_str(),
900 (combined_selectors_ & DEATH_THREAD) ? "*" : 900 (combined_selectors_ & DEATH_THREAD) ? "*" :
901 sample.DeathThreadName().c_str()); 901 sample.DeathThreadName().c_str());
902 sample.birth().location().Write(!(combined_selectors_ & BIRTH_FILE), 902 sample.birth().location().Write(!(combined_selectors_ & BIRTH_FILE),
903 !(combined_selectors_ & BIRTH_FUNCTION), 903 !(combined_selectors_ & BIRTH_FUNCTION),
904 output); 904 output);
905 } 905 }
906 906
907 } // namespace tracked_objects 907 } // namespace tracked_objects
OLDNEW
« no previous file with comments | « base/tracked_objects.h ('k') | net/base/x509_certificate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698