Opened 12 years ago

Closed 10 years ago

#5215 closed Bugs (wontfix)

regex_match is giving a performance hit.

Reported by: arjun_m@… Owned by: John Maddock
Milestone: To Be Determined Component: regex
Version: Boost 1.46.0 Severity: Optimization
Keywords: Cc:

Description

inline bool regex_match(const std::string& s,

const regex& e, match_flag_type flags = match_default)

When an expression like /Volumes/.*/Backups.backupdb/.* is passed to regex_match() then I am experiencing a performance hit. I am using boost library version 1.32.0 (Since this version was not available in the drop down I have selected 1.34.0)

Change History (4)

comment:1 by anonymous, 12 years ago

Version: Boost 1.34.0Boost 1.46.0

comment:2 by anonymous, 12 years ago

Can you please provide some example code that illustrates the problem?

Please also bare in mind that matching a regular expression is in the general case NP-complete. Assuming it doesn't change the semantics of your program then something like:

/Volumes/[^/]*/Backups.backupdb/.*

Should be more efficient. Otherwise try something like:

/Volumes(?:/[^/]*)+?/Backups.backupdb/.*

in reply to:  2 comment:3 by anonymous, 12 years ago

Replying to anonymous:

Can you please provide some example code that illustrates the problem?

Please also bare in mind that matching a regular expression is in the general case NP-complete. Assuming it doesn't change the semantics of your program then something like:

/Volumes/[^/]*/Backups.backupdb/.*

Should be more efficient. Otherwise try something like:

/Volumes(?:/[^/]*)+?/Backups.backupdb/.*

Thanks for the reply.

After I posted this issue, I was trying out different alternatives and found something. The back drop for this issue is that, I am getting exclusion list from the User, based on which I am performing some operations. So I convert the exclusion list to an 'expression' and pass it to regex_match(). The more I add exclusion's , more time is taken by regex_match(). As suggested by I would provide an example code that would illustrate the problem.

Thanks.

comment:4 by John Maddock, 10 years ago

Resolution: wontfix
Status: newclosed

Closed pending update from user.

Note: See TracTickets for help on using tickets.