jeromq icon indicating copy to clipboard operation
jeromq copied to clipboard

Strange l

Open fbacchella opened this issue 4 years ago • 5 comments

I found a strange test in https://github.com/zeromq/jeromq/blob/d2121cf3293862b9ce8e5c6f85bb586ea21328d0/src/main/java/org/zeromq/ZMonitor.java#L99:

The whole function is:

        private static Event find(int event)
        {
            for (Event candidate : Event.values()) {
                if ((candidate.events & event) != 0) {
                    return candidate;
                }
            }
            // never arrives here, but anyway...
            return ALL;
        }
    }

What event is expected to be ? If it's a mask, as the test (candidate.events & event) != 0) implies, many values can fit. It's a single value, why bother with a binary and, an == will do the job ?

fbacchella avatar May 30 '20 18:05 fbacchella

I would check czmq, it's likely this was based of something in there

trevorbernard avatar May 30 '20 18:05 trevorbernard

My comprehension is that org.zeromq is for java-native code, not ported from czmq. There is no ZMonitor in libzmq.

fbacchella avatar May 30 '20 18:05 fbacchella

jeromq is a mashup of both IMHO. Anything prefixed with a Z, the idea/interface most likely came from czmq

trevorbernard avatar May 31 '20 15:05 trevorbernard

I don't remember this particular test coming from czmq. Maybe I was overcautious. Feel free to change it back.

fredoboulo avatar Jun 05 '20 14:06 fredoboulo

But yes, zmq package carries the java equivalent of libzmq, while org.zeromq is inspired from czmq. Both packages are java-native.

fredoboulo avatar Jun 05 '20 14:06 fredoboulo