Skip to content

Commit

Permalink
form_match_list(): Don't use _Atomic
Browse files Browse the repository at this point in the history
There is no need to ensure the "id" variable is incremented in an atomic
way, because we don't care if two threads will use the same value.

The crash that got debugged on commit 9f73b37 was due to another
reason: not using "id" variable if it is 0. This has been fixed.

Removing it gets rid of some small overhead, and also allows MSVC compilation.
  • Loading branch information
ampli committed May 30, 2024
1 parent b4f22e4 commit 3c23a1c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions link-grammar/parse/fast-match.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ form_match_list(fast_matcher_t *ctxt, int w,
}

#ifdef VERIFY_MATCH_LIST
static _Atomic(uint16_t) id = 0;
uint16_t lid = ++id; /* A local copy, for multi-threading support. */
static uint16_t id = 0;
uint16_t lid = ++id; /* A stable local copy, for multi-threading support. */
#else
const uint16_t lid = 0;
#endif
Expand Down

0 comments on commit 3c23a1c

Please sign in to comment.