Skip to content

Commit

Permalink
Refactoring: optimize FileDef::isDocumentationFile() method
Browse files Browse the repository at this point in the history
  • Loading branch information
doxygen committed Jul 3, 2022
1 parent 40869ce commit 20cacf8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/filedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*
*/

#include <unordered_set>

#include "memberlist.h"
#include "classlist.h"
#include "filedef.h"
Expand Down Expand Up @@ -1510,11 +1512,11 @@ void FileDefImpl::combineUsingRelations()

bool FileDefImpl::isDocumentationFile() const
{
return name().right(4)==".doc" ||
name().right(4)==".txt" ||
name().right(4)==".dox" ||
name().right(3)==".md" ||
name().right(9)==".markdown" ||
static const std::unordered_set<std::string> docExtensions =
{ "doc", "txt", "dox", "md", "markdown" };

int lastDot = name().findRev('.');
return (lastDot!=-1 && docExtensions.find(name().mid(lastDot+1).str())!=docExtensions.end()) ||
getLanguageFromFileName(getFileNameExtension(name())) == SrcLangExt_Markdown;
}

Expand Down

0 comments on commit 20cacf8

Please sign in to comment.