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

Unified Diff: src/vector.h

Issue 1204123003: Reland Extend big-disjunction optimization to case-independent regexps (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Skip slow architecture-independent tests on slower CPUs and simulators Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/list-inl.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/vector.h
diff --git a/src/vector.h b/src/vector.h
index d022fde3a5bb25d88b7fba5e9ca4ae375e94d20b..4f3128b9185cd42d21e439913a967c79753cb6f5 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -69,24 +69,30 @@ class Vector {
return Vector<T>(result, length_);
}
- void Sort(int (*cmp)(const T*, const T*), size_t s, size_t l) {
- std::sort(start() + s, start() + s + l, RawComparer(cmp));
+ template <typename CompareFunction>
+ void Sort(CompareFunction cmp, size_t s, size_t l) {
+ std::sort(start() + s, start() + s + l, RawComparer<CompareFunction>(cmp));
}
- void Sort(int (*cmp)(const T*, const T*)) {
- std::sort(start(), start() + length(), RawComparer(cmp));
+ template <typename CompareFunction>
+ void Sort(CompareFunction cmp) {
+ std::sort(start(), start() + length(), RawComparer<CompareFunction>(cmp));
}
void Sort() {
std::sort(start(), start() + length());
}
- void StableSort(int (*cmp)(const T*, const T*), size_t s, size_t l) {
- std::stable_sort(start() + s, start() + s + l, RawComparer(cmp));
+ template <typename CompareFunction>
+ void StableSort(CompareFunction cmp, size_t s, size_t l) {
+ std::stable_sort(start() + s, start() + s + l,
+ RawComparer<CompareFunction>(cmp));
}
- void StableSort(int (*cmp)(const T*, const T*)) {
- std::stable_sort(start(), start() + length(), RawComparer(cmp));
+ template <typename CompareFunction>
+ void StableSort(CompareFunction cmp) {
+ std::stable_sort(start(), start() + length(),
+ RawComparer<CompareFunction>(cmp));
}
void StableSort() { std::stable_sort(start(), start() + length()); }
@@ -136,15 +142,16 @@ class Vector {
T* start_;
int length_;
+ template <typename CookedComparer>
class RawComparer {
public:
- explicit RawComparer(int (*cmp)(const T*, const T*)) : cmp_(cmp) {}
+ explicit RawComparer(CookedComparer cmp) : cmp_(cmp) {}
bool operator()(const T& a, const T& b) {
return cmp_(&a, &b) < 0;
}
private:
- int (*cmp_)(const T*, const T*);
+ CookedComparer cmp_;
};
};
« no previous file with comments | « src/list-inl.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698