Unsigned-right-shift patch

15 views
Skip to first unread message

Cameron

unread,
Aug 23, 2010, 4:15:20 PM8/23/10
to Clojure
Hey all, I had an itch this weekend... so I scratched it.

I was doing some bit twiddling stuff and needed the Java >>> operator.
I had written some workarounds but they were overly-complicated and
slower than I would have hoped, so I dug directly into core and added
it as a first class citizen next to bit-shift-left and bit-shift-
right. Being a very creative person, I named it ">>>". The performance
is on par with the normal signed shift operators.

To anyone who is interested, the patch can be found at:
http://github.com/cpulsford/bitops/blob/logical-assumption/unsigned-right-shift.patch

I'd love feedback, especially since this is my first time digging into
the Java side of Clojure.

Could this maybe be something useful for core?



Alan

unread,
Aug 23, 2010, 5:43:29 PM8/23/10
to Clojure
Without commenting on the usefulness of this (it doesn't really
interest me), there are a couple style things I would change.
First, :added ought to be 1.3 (maybe 1.2?), not 1.0. Second, the
newsgroup seems to think that if you're changing clojure.core you
might as well update from (. staticMember class args) to (class/
staticMember args) while you're in there. You could also fix the other
shift operators if you wanted.

On Aug 23, 1:15 pm, Cameron <cpuls...@gmail.com> wrote:
> Hey all, I had an itch this weekend... so I scratched it.
>
> I was doing some bit twiddling stuff and needed the Java >>> operator.
> I had written some workarounds but they were overly-complicated and
> slower than I would have hoped, so I dug directly into core and added
> it as a first class citizen next to bit-shift-left and bit-shift-
> right. Being a very creative person, I named it ">>>". The performance
> is on par with the normal signed shift operators.
>
> To anyone who is interested, the patch can be found at:http://github.com/cpulsford/bitops/blob/logical-assumption/unsigned-r...

Cameron Pulsford

unread,
Aug 23, 2010, 7:15:53 PM8/23/10
to Clojure
Yes the 1.0 was a slip on my part, and I agree that I should have used
the class/staticMembers syntax; at the time I was simply trying to fit
in.

Regardless, here is the updated patch with those two comments fixed:
http://github.com/cpulsford/bitops/blob/logical-assumption/unsigned-right-shift.patch

I also made a separate patch that fixes ALL the bit operators in the
same way, plus I inlined the few that weren't. This patch can be found
at: http://github.com/cpulsford/bitops/blob/logical-assumption/bitops-revamped.patch
Reply all
Reply to author
Forward
0 new messages