Skip to content

Instantly share code, notes, and snippets.

View jnthn's full-sized avatar

Jonathan Worthington jnthn

View GitHub Profile
@jnthn
jnthn / ffs.c
Created March 8, 2017 12:09 — forked from bdw/ffs.c
cross-platform first set bit
#include <stdio.h>
#include <stdlib.h>
#define MVMint32 int
#ifdef __GNUC__
#define FFS(x) __builtin_ffs(x)
#elif defined(_MSC_VER)
static __inline MVMint32 FFS(MVMint32 x) {
MVMint32 i = 0;
@jnthn
jnthn / objhash.pl
Created February 14, 2012 13:31 — forked from moritz/objhash.pl
First experiments with
class ObjHash {
has %!keys handles (keys => 'values');
has %!values handles <values elems>;
method at_key(Mu $key) is rw {
my $lkey = $key.WHICH;
%!values.exists($lkey)
?? %!values{$lkey}
!! pir::setattribute__0PPsP(my $v, Scalar, '$!whence',
-> {
%!keys{$lkey} := $key;