Commit aac666e7 authored by timothy@apple.com's avatar timothy@apple.com

Use member function pointers for the Profile::forEach function.

        Eliminating a few static functions and simplified things a little.

        Reviewed by Alexey Proskuryakov.

        * JavaScriptCore.exp: Change the symbol for forEach.
        * profiler/Profile.cpp:
        (KJS::Profile::forEach): Use a member function pointer.
        * profiler/Profile.h:
        (KJS::Profile::sortTotalTimeDescending): Pass a function pointer.
        (KJS::Profile::sortTotalTimeAscending): Ditto.
        (KJS::Profile::sortSelfTimeDescending): Ditto.
        (KJS::Profile::sortSelfTimeAscending): Ditto.
        (KJS::Profile::sortCallsDescending): Ditto.
        * profiler/ProfileNode.h:
        (KJS::ProfileNode::sortTotalTimeDescending): No longer static.
        (KJS::ProfileNode::sortTotalTimeAscending): Ditto.
        (KJS::ProfileNode::sortSelfTimeDescending): Ditto.
        (KJS::ProfileNode::sortSelfTimeAscending): Ditto.
        (KJS::ProfileNode::sortCallsDescending): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34712 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f064af60
2008-06-20 Timothy Hatcher <timothy@apple.com>
Use member function pointers for the Profile::forEach function.
Eliminating a few static functions and simplified things a little.
Reviewed by Alexey Proskuryakov.
* JavaScriptCore.exp: Change the symbol for forEach.
* profiler/Profile.cpp:
(KJS::Profile::forEach): Use a member function pointer.
* profiler/Profile.h:
(KJS::Profile::sortTotalTimeDescending): Pass a function pointer.
(KJS::Profile::sortTotalTimeAscending): Ditto.
(KJS::Profile::sortSelfTimeDescending): Ditto.
(KJS::Profile::sortSelfTimeAscending): Ditto.
(KJS::Profile::sortCallsDescending): Ditto.
* profiler/ProfileNode.h:
(KJS::ProfileNode::sortTotalTimeDescending): No longer static.
(KJS::ProfileNode::sortTotalTimeAscending): Ditto.
(KJS::ProfileNode::sortSelfTimeDescending): Ditto.
(KJS::ProfileNode::sortSelfTimeAscending): Ditto.
(KJS::ProfileNode::sortCallsDescending): Ditto.
2008-06-20 Cameron Zwarich <cwzwarich@uwaterloo.ca>
Reviewed by Oliver.
......
......@@ -174,7 +174,7 @@ __ZN3KJS7JSArray4infoE
__ZN3KJS7Profile10restoreAllEv
__ZN3KJS7Profile5focusEPKNS_11ProfileNodeE
__ZN3KJS7Profile7excludeEPKNS_11ProfileNodeE
__ZN3KJS7Profile7forEachEPFvPNS_11ProfileNodeEE
__ZN3KJS7Profile7forEachEMNS_11ProfileNodeEFvvE
__ZN3KJS7UString3Rep11computeHashEPKti
__ZN3KJS7UString3Rep4nullE
__ZN3KJS7UString3Rep7destroyEv
......
......@@ -37,10 +37,6 @@ namespace KJS {
static const char* NonJSExecution = "(idle)";
static void calculateVisibleTotalTime(ProfileNode* n) { n->calculateVisibleTotalTime(); }
static void restoreAll(ProfileNode* n) { n->restore(); }
static void stopProfiling(ProfileNode* n) { n->stopProfiling(); }
PassRefPtr<Profile> Profile::create(const UString& title, ExecState* originatingGlobalExec, unsigned pageGroupIdentifier, ProfilerClient* client)
{
return adoptRef(new Profile(title, originatingGlobalExec, pageGroupIdentifier, client));
......@@ -61,7 +57,7 @@ Profile::Profile(const UString& title, ExecState* originatingGlobalExec, unsigne
void Profile::stopProfiling()
{
forEach(KJS::stopProfiling);
forEach(&ProfileNode::stopProfiling);
removeProfileStart();
removeProfileEnd();
......@@ -163,7 +159,7 @@ void Profile::didExecute(const CallIdentifier& callIdentifier)
m_currentNode = m_currentNode->didExecute();
}
void Profile::forEach(UnaryFunction function)
void Profile::forEach(void (ProfileNode::*function)())
{
ProfileNode* currentNode = m_head->firstChild();
for (ProfileNode* nextNode = currentNode; nextNode; nextNode = nextNode->firstChild())
......@@ -171,7 +167,7 @@ void Profile::forEach(UnaryFunction function)
ProfileNode* endNode = m_head->traverseNextNodePostOrder();
while (currentNode && currentNode != endNode) {
function(currentNode);
(currentNode->*function)();
currentNode = currentNode->traverseNextNodePostOrder();
}
}
......@@ -187,7 +183,7 @@ void Profile::focus(const ProfileNode* profileNode)
processChildren = currentNode->focus(callIdentifier);
// Set the visible time of all nodes so that the %s display correctly.
forEach(KJS::calculateVisibleTotalTime);
forEach(&ProfileNode::calculateVisibleTotalTime);
}
void Profile::exclude(const ProfileNode* profileNode)
......@@ -207,7 +203,7 @@ void Profile::exclude(const ProfileNode* profileNode)
void Profile::restoreAll()
{
forEach(KJS::restoreAll);
forEach(&ProfileNode::restore);
}
#ifndef NDEBUG
......
......@@ -34,7 +34,6 @@ namespace KJS {
class ExecState;
class ProfilerClient;
typedef void (*UnaryFunction)(ProfileNode*);
class Profile : public RefCounted<Profile> {
public:
......@@ -54,15 +53,15 @@ namespace KJS {
unsigned pageGroupIdentifier() const { return m_pageGroupIdentifier; }
ProfilerClient* client() { return m_client; }
void forEach(UnaryFunction);
void sortTotalTimeDescending() { forEach(ProfileNode::sortTotalTimeDescending); }
void sortTotalTimeAscending() { forEach(ProfileNode::sortTotalTimeAscending); }
void sortSelfTimeDescending() { forEach(ProfileNode::sortSelfTimeDescending); }
void sortSelfTimeAscending() { forEach(ProfileNode::sortSelfTimeAscending); }
void sortCallsDescending() { forEach(ProfileNode::sortCallsDescending); }
void sortCallsAscending() { forEach(ProfileNode::sortCallsAscending); }
void sortFunctionNameDescending() { forEach(ProfileNode::sortFunctionNameDescending); }
void sortFunctionNameAscending() { forEach(ProfileNode::sortFunctionNameAscending); }
void forEach(void (ProfileNode::*)());
void sortTotalTimeDescending() { forEach(&ProfileNode::sortTotalTimeDescending); }
void sortTotalTimeAscending() { forEach(&ProfileNode::sortTotalTimeAscending); }
void sortSelfTimeDescending() { forEach(&ProfileNode::sortSelfTimeDescending); }
void sortSelfTimeAscending() { forEach(&ProfileNode::sortSelfTimeAscending); }
void sortCallsDescending() { forEach(&ProfileNode::sortCallsDescending); }
void sortCallsAscending() { forEach(&ProfileNode::sortCallsAscending); }
void sortFunctionNameDescending() { forEach(&ProfileNode::sortFunctionNameDescending); }
void sortFunctionNameAscending() { forEach(&ProfileNode::sortFunctionNameAscending); }
void focus(const ProfileNode* profileNode);
void exclude(const ProfileNode* profileNode);
......
......@@ -121,14 +121,14 @@ namespace KJS {
ProfileNode* traverseNextNodePreOrder(bool processChildren = true) const;
void sort(bool (*)(const RefPtr<ProfileNode>&, const RefPtr<ProfileNode>&));
static void sortTotalTimeDescending(ProfileNode* n) { n->sort(totalTimeDescendingComparator); }
static void sortTotalTimeAscending(ProfileNode* n) { n->sort(totalTimeAscendingComparator); }
static void sortSelfTimeDescending(ProfileNode* n) { n->sort(selfTimeDescendingComparator); }
static void sortSelfTimeAscending(ProfileNode* n) { n->sort(selfTimeAscendingComparator); }
static void sortCallsDescending(ProfileNode* n) { n->sort(callsDescendingComparator); }
static void sortCallsAscending(ProfileNode* n) { n->sort(callsAscendingComparator); }
static void sortFunctionNameDescending(ProfileNode* n) { n->sort(functionNameDescendingComparator); }
static void sortFunctionNameAscending(ProfileNode* n) { n->sort(functionNameAscendingComparator); }
void sortTotalTimeDescending() { sort(totalTimeDescendingComparator); }
void sortTotalTimeAscending() { sort(totalTimeAscendingComparator); }
void sortSelfTimeDescending() { sort(selfTimeDescendingComparator); }
void sortSelfTimeAscending() { sort(selfTimeAscendingComparator); }
void sortCallsDescending() { sort(callsDescendingComparator); }
void sortCallsAscending() { sort(callsAscendingComparator); }
void sortFunctionNameDescending() { sort(functionNameDescendingComparator); }
void sortFunctionNameAscending() { sort(functionNameAscendingComparator); }
void calculateVisibleTotalTime();
bool focus(const CallIdentifier&);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment