This file contains hidden or 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
#include <immintrin.h> | |
#include <stdint.h> | |
int getIndexOf(__m512i const *values, int64_t target) | |
{ | |
__m512i valuesSimd = _mm512_loadu_si512(values); | |
__m512i targetSplatted = _mm512_set1_epi64(target); | |
__mmask8 equalMask = _mm512_cmpeq_epi64_mask(valuesSimd, targetSplatted); | |
uint32_t equalMaskInt = _cvtmask8_u32(equalMask); | |
int index = _tzcnt_u32(equalMaskInt); |
This file contains hidden or 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
%%{ | |
utf8 = | |
( 0..127 | 192..223 128..191 | 224..239 128..191 128..191 | 240..247 128..191 128..191 128..191 ) | |
- ( 244 144..191 any any | 245..247 any any any ) # over U+10FFFF | |
- ( 0xC0..0xC1 any ) # overlong 2-byte encodings | |
- ( 224 128..159 any ) # overlong 3-byte encodings | |
- ( 240 128..143 any any ) # overlong 4-byte encodings | |
- ( 237 160..191 any ) # invalid utf-16 surrogate pairs | |
; | |
main := utf8* ; |
This file contains hidden or 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
// libdivide.h - Optimized integer division | |
// https://libdivide.com | |
// | |
// Copyright (C) 2010 - 2021 ridiculous_fish, <[email protected]> | |
// Copyright (C) 2016 - 2021 Kim Walisch, <[email protected]> | |
// | |
// libdivide is dual-licensed under the Boost or zlib licenses. | |
// You may use libdivide under the terms of either of these. | |
// See LICENSE.txt for more details. |
This file contains hidden or 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" | |
"fmt" | |
"reflect" | |
"regexp" | |
"strconv" | |
"time" | |
) |
This file contains hidden or 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
DECLARE check_running_jobs DEFAULT ( | |
SELECT IF(COUNT(*) > 1, ERROR('query already running'), NULL) | |
FROM `region-name`.INFORMATION_SCHEMA.JOBS_BY_PROJECT | |
WHERE state <> 'DONE' | |
); |
This file contains hidden or 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" | |
"fmt" | |
"hash/maphash" | |
"math/rand" | |
) | |
type Comparable[T any] interface { |
This file contains hidden or 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 reflect_test | |
// Extracted from https://go-review.googlesource.com/c/go/+/401434 | |
import ( | |
"fmt" | |
"reflect" | |
"unsafe" | |
) |
This file contains hidden or 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 shortstring | |
import ( | |
"reflect" | |
"runtime" | |
"unsafe" | |
) | |
type shortstring struct { | |
ptr unsafe.Pointer |
This file contains hidden or 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
#include <immintrin.h> | |
static int lut32x(int32_t *inout, __m512i lutk[], __m512i lutv[], int nlut) { | |
__m512i bin = _mm512_set1_epi32(*inout); | |
for (int i=0; i<nlut; i++) { | |
__mmask16 mask = _mm512_cmpeq_epi32_mask(bin, lutk[i]); | |
if (mask == 0) continue; | |
__m512i bout = _mm512_maskz_compress_epi32(mask, lutv[i]); | |
*inout = _mm_extract_epi32(_mm512_extracti32x4_epi32(bout, 0), 0); |
This file contains hidden or 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 container | |
type BijectiveMap[A, B comparable] struct { | |
m1 map[A]B | |
m2 map[B]A | |
} | |
func (m *BijectiveMap[A, B]) GetB(a A) (B, bool) { | |
if m.m1 == nil { | |
var zero B |