@@ -101,7 +101,7 @@ def to_native(self, copy: bool = False) -> T.List[str]:
101
101
# Remove system/default include paths added with -isystem
102
102
default_dirs = self .compiler .get_default_include_dirs ()
103
103
if default_dirs :
104
- real_default_dirs = [os . path . realpath (i ) for i in default_dirs ]
104
+ real_default_dirs = [self . _cached_realpath (i ) for i in default_dirs ]
105
105
bad_idx_list = [] # type: T.List[int]
106
106
for i , each in enumerate (new ):
107
107
if not each .startswith ('-isystem' ):
@@ -110,16 +110,21 @@ def to_native(self, copy: bool = False) -> T.List[str]:
110
110
# Remove the -isystem and the path if the path is a default path
111
111
if (each == '-isystem' and
112
112
i < (len (new ) - 1 ) and
113
- os . path . realpath (new [i + 1 ]) in real_default_dirs ):
113
+ self . _cached_realpath (new [i + 1 ]) in real_default_dirs ):
114
114
bad_idx_list += [i , i + 1 ]
115
- elif each .startswith ('-isystem=' ) and os . path . realpath (each [9 :]) in real_default_dirs :
115
+ elif each .startswith ('-isystem=' ) and self . _cached_realpath (each [9 :]) in real_default_dirs :
116
116
bad_idx_list += [i ]
117
- elif os . path . realpath (each [8 :]) in real_default_dirs :
117
+ elif self . _cached_realpath (each [8 :]) in real_default_dirs :
118
118
bad_idx_list += [i ]
119
119
for i in reversed (bad_idx_list ):
120
120
new .pop (i )
121
121
return self .compiler .unix_args_to_native (new ._container )
122
122
123
+ @staticmethod
124
+ @functools .lru_cache (maxsize = None )
125
+ def _cached_realpath (arg : str ) -> str :
126
+ return os .path .realpath (arg )
127
+
123
128
def __repr__ (self ) -> str :
124
129
self .flush_pre_post ()
125
130
return f'CLikeCompilerArgs({ self .compiler !r} , { self ._container !r} )'
0 commit comments