##// END OF EJS Templates
match: improve includematcher.visitchildrenset to be much faster and cached...
match: improve includematcher.visitchildrenset to be much faster and cached This improves the speed of visitchildrenset considerably, especially when there are complicated matchers involved that may have many entries in _dirs or _parents. Unfortunately the benchmark isn't easily upstreamed due to its reliance on https://github.com/vstinner/perf (primarily due to the conflict when importing it if I were to contribute the benchmark as contrib/matcherbenchmarks.py) instead of asv or some other perf measurement system. To describe the benchmark briefly: I generated an includematcher of either 5 or 3500 "rootfilesin:prefix1/prefix2/prefix3/<randomsubdirs, 1-8 levels deep>" items in the 'setup' function, and then called `im.visitchildrenset('prefix1/prefix2')` in the 'stmt' function in perf.timeit. For the set of 5: - before: 15.3 us +- 2.9 us - after: 1.59 us +- 0.02 us For the set of 3500: - before: 3.90 ms +- 0.10 ms - after: 3.15 us +- 0.09 us (note the m->u change) Differential Revision: https://phab.mercurial-scm.org/D4351

File last commit:

r35977:9724f549 default
r39494:35ecaa99 default
Show More
util.h
35 lines | 855 B | text/x-c | CLexer
/*
* Utility functions
*
* Copyright (c) 2011 Yuya Nishihara <yuya@tcha.org>
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2 or any later version.
*/
#ifndef UTIL_H_
#define UTIL_H_
#ifdef __GNUC__
#define PRINTF_FORMAT_ __attribute__((format(printf, 1, 2)))
#define UNUSED_ __attribute__((unused))
#else
#define PRINTF_FORMAT_
#define UNUSED_
#endif
void abortmsg(const char *fmt, ...) PRINTF_FORMAT_;
void abortmsgerrno(const char *fmt, ...) PRINTF_FORMAT_;
void enablecolor(void);
void enabledebugmsg(void);
void debugmsg(const char *fmt, ...) PRINTF_FORMAT_;
void fchdirx(int dirfd);
void fsetcloexec(int fd);
void *mallocx(size_t size);
void *reallocx(void *ptr, size_t size);
int runshellcmd(const char *cmd, const char *envp[], const char *cwd);
#endif /* UTIL_H_ */