aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-12-20 12:46:33 +0000
committergingerBill <bill@gingerbill.org>2022-12-20 12:46:33 +0000
commit0edda2bea769303166eaab2965f6cfb8b2bd807c (patch)
tree16723d7222d7a86a5fb6704f8e79b35ebaa5a5cd /src/parser.cpp
parenta13e2f4578eb5557afb8bc6b21930032bedbbb43 (diff)
Clarify ThreadPool interface; Move `import_mutex` guarding to just the string set
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 520f123d8..eb006cb24 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -4966,14 +4966,12 @@ gb_internal void parser_add_foreign_file_to_process(Parser *p, AstPackage *pkg,
gb_internal AstPackage *try_add_import_path(Parser *p, String const &path, String const &rel_path, TokenPos pos, PackageKind kind = Package_Normal) {
String const FILE_EXT = str_lit(".odin");
- mutex_lock(&p->import_mutex);
- defer (mutex_unlock(&p->import_mutex));
-
- if (string_set_exists(&p->imported_files, path)) {
- return nullptr;
+ MUTEX_GUARD_BLOCK(&p->import_mutex) {
+ if (string_set_exists(&p->imported_files, path)) {
+ return nullptr;
+ }
+ string_set_add(&p->imported_files, path);
}
- string_set_add(&p->imported_files, path);
-
AstPackage *pkg = gb_alloc_item(permanent_allocator(), AstPackage);
pkg->kind = kind;
@@ -4991,8 +4989,8 @@ gb_internal AstPackage *try_add_import_path(Parser *p, String const &path, Strin
fi.is_dir = false;
pkg->is_single_file = true;
- parser_add_file_to_process(p, pkg, fi, pos);
parser_add_package(p, pkg);
+ parser_add_file_to_process(p, pkg, fi, pos);
return pkg;
}