aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2018-11-02 14:26:07 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2018-11-02 21:04:13 +0200
commit388108aa88b8fd44a450f71badd2c3ca5fda1bda (patch)
tree41a7a7481c7f8695adcf7f20bf4dd2d057aacccd /mesonbuild
parentcd369aceee8fdde4096de228171cdf80061d3cfe (diff)
downloadmeson-388108aa88b8fd44a450f71badd2c3ca5fda1bda.zip
meson-388108aa88b8fd44a450f71badd2c3ca5fda1bda.tar.gz
meson-388108aa88b8fd44a450f71badd2c3ca5fda1bda.tar.bz2
meson: performance optimizethe file object
reduce the amount of access calls to the os. This safes ~1 sec. build time
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/mesonlib.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index d9cbe11..59d4f81 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -21,6 +21,7 @@ import time
import platform, subprocess, operator, os, shutil, re
import collections
from enum import Enum
+from functools import lru_cache
from mesonbuild import mlog
@@ -223,6 +224,7 @@ class File:
return ret.format(self.relative_name())
@staticmethod
+ @lru_cache(maxsize=None)
def from_source_file(source_root, subdir, fname):
if not os.path.isfile(os.path.join(source_root, subdir, fname)):
raise MesonException('File %s does not exist.' % fname)
@@ -236,12 +238,14 @@ class File:
def from_absolute_file(fname):
return File(False, '', fname)
+ @lru_cache(maxsize=None)
def rel_to_builddir(self, build_to_src):
if self.is_built:
return self.relative_name()
else:
return os.path.join(build_to_src, self.subdir, self.fname)
+ @lru_cache(maxsize=None)
def absolute_path(self, srcdir, builddir):
absdir = srcdir
if self.is_built:
@@ -260,6 +264,7 @@ class File:
def __hash__(self):
return hash((self.fname, self.subdir, self.is_built))
+ @lru_cache(maxsize=None)
def relative_name(self):
return os.path.join(self.subdir, self.fname)