mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-02 03:42:30 +00:00
QTC: cache get_env results for improved performance
It turns out that QUtil::get_env is particularly expensive on Windows if there is a large environment. This may be true on other platforms as well.
This commit is contained in:
parent
32e30a3af2
commit
da71dc6f37
2
TODO
2
TODO
@ -10,6 +10,8 @@ Before Release:
|
||||
* Cache environment variables
|
||||
* Remove coverage cases for things that are heavily exercised or are
|
||||
in critical paths
|
||||
* Make ./performance_check usable by other people by having published
|
||||
files to use for testing.
|
||||
* Evaluate issues tagged with `next`
|
||||
* Stay on top of https://github.com/pikepdf/pikepdf/pull/315
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <qpdf/QUtil.hh>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <stdio.h>
|
||||
|
||||
static bool
|
||||
@ -14,12 +15,19 @@ tc_active(char const* const scope)
|
||||
void
|
||||
QTC::TC(char const* const scope, char const* const ccase, int n)
|
||||
{
|
||||
static std::set<std::pair<std::string, int>> cache;
|
||||
static std::map<std::string, bool> active;
|
||||
auto is_active = active.find(scope);
|
||||
if (is_active == active.end()) {
|
||||
active[scope] = tc_active(scope);
|
||||
is_active = active.find(scope);
|
||||
}
|
||||
|
||||
if (!tc_active(scope)) {
|
||||
if (!is_active->second) {
|
||||
return;
|
||||
}
|
||||
|
||||
static std::set<std::pair<std::string, int>> cache;
|
||||
|
||||
std::string filename;
|
||||
#ifdef _WIN32
|
||||
# define TC_ENV "TC_WIN_FILENAME"
|
||||
|
Loading…
Reference in New Issue
Block a user