From d74d9f4e60e48260ff1fad3ff00aaf000f111a66 Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 22 Oct 2010 14:00:01 +0000 Subject: Increased gnu make compatibility Optimised --- tools/mhmake/src/fileinfo.h | 98 +++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 53 deletions(-) (limited to 'tools/mhmake/src/fileinfo.h') diff --git a/tools/mhmake/src/fileinfo.h b/tools/mhmake/src/fileinfo.h index 3c7917be3..8d58a1efa 100644 --- a/tools/mhmake/src/fileinfo.h +++ b/tools/mhmake/src/fileinfo.h @@ -1,6 +1,6 @@ /* This file is part of mhmake. * - * Copyright (C) 2001-2009 Marc Haesen + * Copyright (C) 2001-2010 marha@sourceforge.net * * Mhmake is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -130,22 +130,21 @@ inline ostream& operator<<(ostream& out,const mh_time &Src) return out; } -class fileinfo : public refbase +class fileinfo { string m_AbsFileName; bool m_IsPhony; int m_BuildStatus; /* Bit 0 means the target built is started, Bit 1 means the target is still building */ refptr m_pRule; mhmakeparser *m_pAutoDepsMakefile; - vector< refptr > m_Deps; + vector m_Deps; mh_time_t m_Date; uint32 m_CommandsMd5_32; // 32-bit Md5 checksum of commands to build this target fileinfo(const fileinfo &Src); fileinfo(void); -public: - fileinfo(const string &AbsFileName,uint32 Md5_32) + void init(const string &AbsFileName,uint32 Md5_32) { m_IsPhony=false; m_pAutoDepsMakefile=NULL; @@ -158,9 +157,15 @@ public: cout << "Initialising Md5 of "< GetDir(void) const; + fileinfo* GetDir(void) const; string GetName() const; bool IsDir() const; @@ -241,28 +238,28 @@ public: } } - refptr GetRule(void) + refptr GetRule(void) const { return m_pRule; } - void AddDep(const refptr &Dep) + void AddDep(fileinfo *pDep) { - if (&*Dep==this) + if (&*pDep==this) { #ifdef _DEBUG cout << GetQuotedFullFileName()<<" is directly dependent on itself\n"; #endif return; } - m_Deps.push_back(Dep); + m_Deps.push_back(pDep); } - void AddDeps(vector< refptr > &Deps); + void AddDeps(vector &Deps); - void InsertDeps(vector< refptr > &Deps) + void InsertDeps(vector &Deps) { - vector< refptr > NewDeps; - vector< refptr >::const_iterator It=Deps.begin(); - vector< refptr >::const_iterator ItEnd=Deps.end(); + vector NewDeps; + vector::const_iterator It=Deps.begin(); + vector::const_iterator ItEnd=Deps.end(); while (It!=ItEnd) { if (&**It==this) @@ -278,18 +275,18 @@ public: if (NewDeps.size()) m_Deps.insert(m_Deps.begin(),NewDeps.begin(),NewDeps.end()); } - void AddMainDep(refptr &MainDep) + void AddMainDep(fileinfo* pMainDep) { - if (&*MainDep==this) + if (&*pMainDep==this) { #ifdef _DEBUG cout << GetQuotedFullFileName()<<" is directly dependent on itself\n"; #endif return; } - m_Deps.insert(m_Deps.begin(),MainDep); + m_Deps.insert(m_Deps.begin(),pMainDep); } - vector< refptr > &GetDeps(void) + vector &GetDeps(void) { return m_Deps; } @@ -311,11 +308,11 @@ public: m_IsPhony=true; m_Date.SetNotExist(); // This will sure that this target will always be build (even if a corresponding file exists) } - bool IsPhony(void) + bool IsPhony(void) const { return m_IsPhony; } - mh_time_t realGetDate(void); + mh_time_t realGetDate(void) const; void SetDateToNow(void); void SetDate(mh_time_t Date) @@ -332,7 +329,7 @@ public: m_Date.Invalidate(); } - mh_time_t GetDate(void) + mh_time_t GetDate(void) const { if (m_Date.IsDateValid()) return m_Date; @@ -343,7 +340,7 @@ public: { // this is used to make sure that this item is rebuild, even if it really exists m_Date.SetNotExist(); } - bool Exists(void) + bool Exists(void) const { return GetDate().DoesExist(); } @@ -402,14 +399,6 @@ public: } }; -struct less_refptrfileinfo : public binary_function , refptr, bool> -{ - bool operator()(const refptr& _Left, const refptr& _Right) const - { - return less().operator ()(_Left->GetFullFileName(),_Right->GetFullFileName()); - } -}; - struct less_fileinfo : public binary_function { bool operator()(const fileinfo *_Left, const fileinfo *_Right) const @@ -418,31 +407,34 @@ struct less_fileinfo : public binary_function NullFileInfo; +fileinfo *GetFileInfo(const string &szName,const fileinfo* pRelDir); -const refptr &GetFileInfo(const string &szName,const refptr &pRelDir); +class fileinfos : public set +{ + public: + ~fileinfos(); +}; -extern set,less_refptrfileinfo > g_FileInfos; +extern fileinfos g_FileInfos; -inline const refptr &GetAbsFileInfo(const string &strAbsName) +inline fileinfo *GetAbsFileInfo(const string &strAbsName) { - static refptr SearchFileInfo(new fileinfo("")); - SearchFileInfo->SetFullFileName(strAbsName); + static fileinfo SearchFileInfo(""); + SearchFileInfo.SetFullFileName(strAbsName); /* Using find is just an optimalisation, you could use insert immediately */ - set,less_refptrfileinfo >::const_iterator pFind=g_FileInfos.find(SearchFileInfo); + fileinfos::const_iterator pFind=g_FileInfos.find(&SearchFileInfo); if (pFind==g_FileInfos.end()) { - pair ,less_refptrfileinfo >::iterator, bool> pPair=g_FileInfos.insert(new fileinfo(SearchFileInfo->GetFullFileName())); + pair pPair=g_FileInfos.insert(new fileinfo(SearchFileInfo.GetFullFileName())); return *(pPair.first); } else return *pFind; } -inline const refptr &GetFileInfo(const char *szName,const refptr &RelDir) +inline fileinfo *GetFileInfo(const char *szName,const fileinfo* pRelDir) { - return GetFileInfo(string(szName),RelDir); + return GetFileInfo(string(szName),pRelDir); } string &NormalizePathName(string &Name); -- cgit v1.2.3