Skip to content

Instantly share code, notes, and snippets.

View matter123's full-sized avatar

Matthew Fosdick matter123

View GitHub Profile
/Users/mfosdick/slow.cpp
source.cpp
source.cpp.embedded.macro
requested grammar outside of this repository
requested grammar outside of this repository
total time: 96775.84208899736ms
match failure
pattern name average time total time peak time
source.cpp:5809 4188.354939 96332.164 32609.107
@matter123
matter123 / sqlite3 perf
Created August 8, 2019 23:56
sqlite3 grammar perf
match failure
pattern name average time total time
source.c:3632 0.008575 12.176
source.c:3732 0.007287 7.578
source.c:3655 0.005987 0.006
source.c:3654 0.005895 61.735
source.c:154 0.004502 0.027
source.c:3782 0.003931 0.016
source.c:3773 0.003578 2.011
source.c:2306 0.003501 1926.857
@matter123
matter123 / debug.tmLanguage.json
Created July 6, 2019 19:16
debug.tmLanguage.json
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Debug",
"patterns": [
{
"include": "#next"
},
{
"begin": "check for\\s*",
"end": "(?!\\G)",
hex|opcode  
---+------  
00 | NOP  
01 | STP  
02 | PSE  
03 | RST  
04 | LOG imm  
05 | LOG mem  
06 | INT 
[COMPILERS]
COUNT=2
PREFIX1=i586-elf
PREFIX2=x86_64-elf
ARCH1=86
ARCH2=64
LINK1=linkx86
LINK2=linkx64
[VENDOR86]
static int sock;
addrinfo *info;
int Init(const char *addr,int port) {
addrinfo hints, *res;
memset(&hints,0,sizeof(addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
hints.ai_protocol = 0;
hints.ai_canonname = NULL;
char *strlcpy(char *dest, const char *src, size_t num) {
bool zero=false;
char *d=dest;
while(num) {
if(!zero) {
int len=get_char_len(src);
if(len>=num||!*src) {
zero=true;
} else {
char_copy(dest,src);
int get_char_len(const char *str) {
unsigned char c=*str;
//if not a start of char return -1
if(c&0xC0==0x80) {
return -1;
}
//number of high one's is total byte count
uint8_t count=1;
while(c&0x80==0x80) {
count++;
int get_char_len(const char *str);
char * next_char(const char *str);
char * get_next_char(const char *str, size_t count);
bool is_char_equal(const char *c1, const char *c2);