diff --git a/src/fsevents/fsevents_stubs.c b/src/fsevents/fsevents_stubs.c index c1c657972133..6d7aee40ba0e 100644 --- a/src/fsevents/fsevents_stubs.c +++ b/src/fsevents/fsevents_stubs.c @@ -261,20 +261,22 @@ static const FSEventStreamEventFlags action_mask = kFSEventStreamEventFlagItemCreated | kFSEventStreamEventFlagItemRemoved | kFSEventStreamEventFlagItemRenamed | kFSEventStreamEventFlagItemModified; +static int count_set_bits(uint32_t bits) { + // XXX slow + int count = 0; + while (bits) { + count += (bits & 1); + bits >>= 1; + } + return count; +} + CAMLprim value dune_fsevents_action(value v_flags) { CAMLparam1(v_flags); CAMLlocal1(v_action); uint32_t flags = Int32_val(v_flags) & action_mask; - // XXX slow - int count = 0; - while (flags) { - count += (flags & 1); - flags >>= 1; - } - - flags = Int32_val(v_flags); - if (count >= 2 || flags & kFSEventStreamEventFlagItemRenamed) { + if (flags & kFSEventStreamEventFlagItemRenamed || count_set_bits(flags)) { // we don't bother tracking renamed acurately for now. macos makes it // tricky by not telling is which path is created and which one is deleted. // it is possible to reverse engineer this from the chain of inodes in the