Skip to content

Commit 103a43e

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 <[email protected]>
1 parent e7664c3 commit 103a43e

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

compat/win32/fscache.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ static struct hashmap map;
99
static CRITICAL_SECTION mutex;
1010
static struct trace_key trace_fscache = TRACE_KEY_INIT(FSCACHE);
1111

12-
int fscache_is_enabled(void)
13-
{
14-
return enabled;
15-
}
16-
1712
/*
1813
* An entry in the file system cache. Used for both entire directory listings
1914
* and file entries.
@@ -257,7 +252,7 @@ static void fscache_clear(void)
257252
/*
258253
* Checks if the cache is enabled for the given path.
259254
*/
260-
static inline int fscache_enabled(const char *path)
255+
int fscache_enabled(const char *path)
261256
{
262257
return enabled > 0 && !is_absolute_path(path);
263258
}

compat/win32/fscache.h

Lines changed: 2 additions & 2 deletions
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);

dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ static int add_excludes(const char *fname, const char *base, int baselen,
810810
size_t size = 0;
811811
char *buf;
812812

813-
if (is_fscache_enabled()) {
813+
if (is_fscache_enabled(fname)) {
814814
if (lstat(fname, &st) < 0) {
815815
fd = -1;
816816
} else {

git-compat-util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ static inline int is_missing_file_error(int errno_)
12791279
#endif
12801280

12811281
#ifndef is_fscache_enabled
1282-
#define is_fscache_enabled() (0)
1282+
#define is_fscache_enabled(path) (0)
12831283
#endif
12841284

12851285
extern int cmd_main(int, const char **);

0 commit comments

Comments
 (0)