This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(global) { "use strict"; | |
var each = function(obj, iterator, context) { | |
if (obj == null) return; | |
if (Array.prototype.forEach && obj.forEach === Array.prototype.forEach) { | |
obj.forEach(iterator, context); | |
} else if (isArray(obj)) { | |
for (var i = 0, l = obj.length; i < l; i++) { | |
if (iterator.call(context, obj[i], i, obj) === {}) return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { "use strict"; | |
var global = this; | |
/** | |
* Each iterator. | |
* | |
* @param {object} props | |
* @param {function} func | |
* @param {object} [context] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cowPool sync.Pool | |
func acquireCow(r io.Reader) *cow { | |
if c, ok := cowPool.Get().(*cow); ok { | |
c.r = r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example shows how interfaces could be used without | |
// pushing inner data to heap. | |
// | |
// Note that it was checked with Go 1.8.3 and may become unuseful | |
// in the future releases of Go. | |
package main | |
import ( | |
"encoding/binary" | |
"testing" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"runtime" | |
"sync" | |
"sync/atomic" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/binary" | |
"flag" | |
"fmt" | |
"log" | |
"os" | |
"reflect" | |
"runtime" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func log2(n uint) uint { | |
const uintBits = 32 << (^uint(0) >> 63) | |
var ( | |
seen, bit uint | |
m, l, r uint | |
) | |
r = uintBits | |
for l < r { | |
m = l + (r-l)/2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Say you want to search 0x22 symbol in two bytes of 0x2122 | |
// you make mask for your search as 0x2222 | |
// then: | |
// | |
// 00100001 00100010 | |
// ^ 00100010 00100010 | |
// ------------------- | |
// 00000011 00000000 00000011 00000000 | |
// & 01111111 11111111 (cut topmost bit) & 10000000 10000000 (save restore mask) | |
// ------------------- ------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"sync" | |
"time" | |
) | |
var withLock = flag.Bool("lock", false, "use lock on resets") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>UUID</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
NewerOlder