From f0b65135c4a9d1b2a90ae446c27837b50ba6ba35 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 10 Oct 2014 13:25:31 +0300 Subject: [PATCH] Only get DataTransform directory contents when needed --- source/datatransform.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/datatransform.cpp b/source/datatransform.cpp index 67b892e..31aaa37 100644 --- a/source/datatransform.cpp +++ b/source/datatransform.cpp @@ -28,15 +28,23 @@ void DataTransform::find_dependencies() else { builder.get_logger().log("files", format("Reading imports from %s", path.str())); - - list dir_files = list_files(FS::dirname(path)); IO::File in(path.str()); DataFile::Parser parser(in, path.str()); + + list dir_files; while(!in.eof()) { DataFile::Statement st = parser.parse(); if(st.keyword=="for_each") { + // There's bound to be at least one file: the transform itself + if(dir_files.empty()) + { + FS::Path dir = FS::dirname(path); + builder.get_logger().log("files", format("Traversing %s", dir.str())); + dir_files = list_files(dir); + } + for(DataFile::Statement::Arguments::const_iterator i=st.args.begin(); i!=st.args.end(); ++i) { Regex re(i->get()); -- 2.45.2