Hacker Newsnew | past | comments | ask | show | jobs | submit | GregWright's commentslogin

3 milliseconds, man, the C optimizers blow my mind, they basically just cheat and stick the answer in there. :-)

[C]cat sum.c #include <stdio.h> int main(void) { unsigned long long sum = 0, i; for (i = 0; i <= 1000000000; i++) //one billion sum += i; printf("%lld\n", sum); //500000000500000000 return 0; }

[C]time ./a.out 500000000500000000

real 0m0.003s user 0m0.001s sys 0m0.001s [C]gcc -O3 -S sum.c [C]cat sum.s .section __TEXT,__text,regular,pure_instructions .globl _main .align 4, 0x90 _main: Leh_func_begin1: pushq %rbp Ltmp0: movq %rsp, %rbp Ltmp1: leaq L_.str(%rip), %rdi movabsq $500000000500000000, %rsi xorb %al, %al callq _printf xorl %eax, %eax popq %rbp ret


No expert, but from the source it looks like it just uses whatever a 'map' uses to match keys:

  (defn frequencies
    "Returns a map from distinct items in coll to the number of times
    they appear."
    {:added "1.2"
     :static true}
    [coll]
    (persistent!
     (reduce (fn [counts x]
               (assoc! counts x (inc (get counts x 0))))
             (transient {}) coll)))


I would love to use this, but apps I work on are both web browser based and native clients. Persona does not yet work with native apps (Android, iOS native apps); it only supports browser based auth right now.

Browser only auth doesn't get me all the way there. I can look at wrapping UIWebKit, or whatever, in my apps, but I bet I am just asking for some hurt. :-)


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: