Skip to content

Commit 73cdb83

Browse files
jeffhostetlerdscho
authored andcommitted
fscache: make fscache_enabled() public
Make fscache_enabled() function public rather than static. Remove unneeded fscache_is_enabled() function. Change is_fscache_enabled() macro to call fscache_enabled(). is_fscache_enabled() now takes a pathname so that the answer is more precise and mean "is fscache enabled for this pathname", since fscache only stores repo-relative paths and not absolute paths, we can avoid attempting lookups for absolute paths. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
1 parent aa0805a commit 73cdb83

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

Diff for: compat/win32/fscache.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ static struct hashmap map;
1212
static CRITICAL_SECTION mutex;
1313
static struct trace_key trace_fscache = TRACE_KEY_INIT(FSCACHE);
1414

15-
int fscache_is_enabled(void)
16-
{
17-
return enabled;
18-
}
19-
2015
/*
2116
* An entry in the file system cache. Used for both entire directory listings
2217
* and file entries.
@@ -273,7 +268,7 @@ static void fscache_clear(void)
273268
/*
274269
* Checks if the cache is enabled for the given path.
275270
*/
276-
static inline int fscache_enabled(const char *path)
271+
int fscache_enabled(const char *path)
277272
{
278273
return enabled > 0 && !is_absolute_path(path);
279274
}

Diff for: compat/win32/fscache.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
int fscache_enable(int enable);
55
#define enable_fscache(x) fscache_enable(x)
66

7-
int fscache_is_enabled(void);
8-
#define is_fscache_enabled() (fscache_is_enabled())
7+
int fscache_enabled(const char *path);
8+
#define is_fscache_enabled(path) fscache_enabled(path)
99

1010
DIR *fscache_opendir(const char *dir);
1111
int fscache_lstat(const char *file_name, struct stat *buf);

Diff for: dir.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ static int add_patterns(const char *fname, const char *base, int baselen,
11151115
size_t size = 0;
11161116
char *buf;
11171117

1118-
if (is_fscache_enabled()) {
1118+
if (is_fscache_enabled(fname)) {
11191119
if (lstat(fname, &st) < 0) {
11201120
fd = -1;
11211121
} else {

Diff for: git-compat-util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ static inline int is_missing_file_error(int errno_)
15731573
#endif
15741574

15751575
#ifndef is_fscache_enabled
1576-
#define is_fscache_enabled() (0)
1576+
#define is_fscache_enabled(path) (0)
15771577
#endif
15781578

15791579
int cmd_main(int, const char **);

0 commit comments

Comments
 (0)