Skip to content

Instantly share code, notes, and snippets.

// NOW
/// We use this to return multiple fns with different signatures
const AppendedSliceGetter = struct { @"fn": anytype };
fn ConstWrappedSlice(comptime Self: type, comptime Elem: type) type {
if (!comptime std.meta.trait.is(.Pointer)(Self)) return []const Elem;
return if (@typeInfo(Self).Pointer.is_const) []const Elem else []Elem;
}
// Rules that will be inlined.
let underscore_sep = r => seq(r, repeat(
seq(optional("_"), r),
));
let bin = /[01]/;
let oct = /[0-7]/;
let dec = /[0-9]/;
let hex = /[0-9a-fA-F]/;
const std = @import("std");
const trait = std.meta.trait;
const assert = std.debug.assert;
fn NextCase(comptime src_error_set: type, comptime dst_error_set: type) type {
const src_errors = @typeInfo(src_error_set).ErrorSet.?;
const dst_errors = @typeInfo(dst_error_set).ErrorSet orelse @compileError("Cannot dispatch into anyerror");
if (dst_errors.len == 0)
@compileError("Destination set is empty.");
usingnamespace @import("PeerType/PeerType.zig");
const std = @import("std");
fn MixtimeType(comptime description: anytype, comptime Tuple: type) type {
const Context = enum { compiletime, runtime };
const StructField = std.builtin.TypeInfo.StructField;
const tuple_fields = std.meta.fields(Tuple);
var struct_field_data: [tuple_fields.len]StructField = undefined;
var extra_error_msg: []const u8 = "Extraneous fields:\n";
@alexnask
alexnask / README.md
Last active July 5, 2020 05:44
ctregex vs pcre

PCRE2 library and benchmark compiled with JIT support with -O3
Pattern compiled with PCRE2_UTF
ctregex example compiled with --release-fast and use .encoding = .utf8
Example file of 525MB, benchmark cosists of iterating through every line and matching the pattern in the line without anchors (aka search) ten times for every pattern and setting, after warming up.

Loading data...
Took 0.72sec
Loaded 8656014 lines, 543369275Bi
===========================================
Testing pattern "διακοπεί" on 8656014 lines...
Pattern found 10 times
Took 495ms
1096.15MBi/sec
Pattern found 10 times
Took 499ms
error.Unexpected NTSTATUS=0xc00000ba
C:\dev\zig\build-release\lib\zig\std\debug.zig:419:53: 0x7ff7871f9e80 in std.debug.writeCurrentStackTraceWindows (build.obj)
const n = windows.ntdll.RtlCaptureStackBackTrace(0, addr_buf.len, @ptrCast(**c_void, &addr_buf), null);
^
C:\dev\zig\build-release\lib\zig\std\debug.zig:404:45: 0x7ff7871e364a in std.debug.writeCurrentStackTrace (build.obj)
return writeCurrentStackTraceWindows(out_stream, debug_info, tty_config, start_addr);
^
C:\dev\zig\build-release\lib\zig\std\debug.zig:125:31: 0x7ff7871e246d in std.debug.dumpCurrentStackTrace (build.obj)
writeCurrentStackTrace(stderr, debug_info, detectTTYConfig(), start_addr) catch |err| {
^
pub fn ChildRecursive(comptime T: type) type {
var V = T;
while (std.meta.trait.is(.Array)(V) or std.meta.trait.is(.Pointer)(V)) : (V = std.meta.Child(V)) {}
return V;
}
const std = @import("std");
const GuildJson = struct {
id: []const u8,
name: []const u8,
icon: []const u8,
owner: bool,
permissions: u53,
features: [][]const u8,
};
usingnamespace @import("std").builtin;
pub const endian = Endian.Little;
pub const output_mode = OutputMode.Obj;
pub const link_mode = LinkMode.Static;
pub const is_test = false;
pub const single_threaded = false;
/// Deprecated: use `std.Target.cpu.arch`
pub const arch = Arch.x86_64;
pub const abi = Abi.gnu;