Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Worthington jnthn

View GitHub Profile
@jnthn
jnthn / ffs.c
Created Mar 8, 2017 — forked from bdw/ffs.c
cross-platform first set bit
View ffs.c
#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 Feb 14, 2012 — forked from moritz/objhash.pl
First experiments with
View objhash.pl
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;