Skip to content

Commit

Permalink
feat: Add simdjson to the stack.
Browse files Browse the repository at this point in the history
This one is quite fast. If we ever need to do fast json parsing, this is
the one for it.
  • Loading branch information
iphydf committed Jan 25, 2025
1 parent 49f7528 commit 77c4f01
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 1 deletion.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ build --per_file_copt='external/sdl2[:/]@-Wno-pedantic'
build --per_file_copt='external/sdl2[:/]@-Wno-sign-compare'
build --per_file_copt='external/sdl2[:/]@-Wno-tautological-value-range-compare'
build --per_file_copt='external/sdl2[:/]@-Wno-unused-but-set-variable'
build --per_file_copt='external/simdjson[:/]@-Wno-unused-member-function'
build --per_file_copt='external/sqlcipher[:/]@-Wno-atomic-implicit-seq-cst'
build --per_file_copt='external/sqlcipher[:/]@-Wno-cast-function-type-strict'
build --per_file_copt='external/sqlcipher[:/]@-Wno-empty-translation-unit'
Expand Down
84 changes: 83 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,2 +1,84 @@
BasedOnStyle: Google
---
# Language
Standard: Cpp11

# Indentation
IndentWidth: 4
ContinuationIndentWidth: 4
AccessModifierOffset: -4
IndentCaseLabels: false
NamespaceIndentation: None

# Spacing
UseTab: Never
SpaceBeforeParens: ControlStatements
SpacesBeforeTrailingComments: 1
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInCStyleCastParentheses: false
SpaceBeforeAssignmentOperators: true
MaxEmptyLinesToKeep: 2

# Alignment
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true

# Argument Packing
BinPackArguments: true
BinPackParameters: true

# Break handling
ColumnLimit: 100
BreakBeforeBraces: Mozilla
BreakBeforeBinaryOperators: NonAssignment
BreakConstructorInitializersBeforeComma: true
AlwaysBreakTemplateDeclarations: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Cpp11BracedListStyle: true

# Break penalities
PenaltyBreakBeforeFirstCallParameter: 200
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 5
PenaltyReturnTypeOnItsOwnLine: 60

# Includes
SortIncludes: true
IncludeIsMainRegex: '([-_](test|fuzz_test))?$'
IncludeBlocks: Regroup
IncludeCategories:
# Match local headers
- Regex: '^"[[:alnum:]_]+\.h"$'
Priority: 1
# Match project headers
- Regex: '^"[[:alnum:]_]+/.+\.h"$'
Priority: 2
# Match Qt headers
- Regex: '^<Q[[:alnum:]_/]+>$'
Priority: 3
# Match other headers
- Regex: '.*'
Priority: 4

# Short blocks
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty

# Set pointer format
DerivePointerAlignment: false
PointerAlignment: Left

# "const X" instead of "X const"
QualifierAlignment: Left
...
8 changes: 8 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,14 @@ http_archive(
urls = ["https://github.com/nlohmann/json/releases/download/v3.11.3/include.zip"],
)

# https://github.com/simdjson/simdjson/releases
new_github_archive(
name = "simdjson",
integrity = "sha256-hl/62dOtM7ARIHS6iJ7pNNtT1hPq/GOS7A0aDJ5bAFc=",
repo = "simdjson/simdjson",
version = "v3.11.6",
)

# https://github.com/libunwind/libunwind/releases
http_archive(
name = "libunwind",
Expand Down
9 changes: 9 additions & 0 deletions third_party/simdjson.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "simdjson",
srcs = ["singleheader/simdjson.cpp"],
hdrs = ["singleheader/simdjson.h"],
includes = ["singleheader"],
visibility = ["//visibility:public"],
)

0 comments on commit 77c4f01

Please sign in to comment.