Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
Go
Haskell
HLSL
Hook
Hylo
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Nim
Objective-C
Objective-C++
OCaml
OpenCL C
Pascal
Pony
Python
Racket
Ruby
Rust
Snowball
Scala
Solidity
Spice
Swift
LLVM TableGen
Toit
TypeScript Native
V
Vala
Visual Basic
Zig
Javascript
GIMPLE
swift source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
x86-64 swiftc 3.1.1
x86-64 swiftc 4.0.2
x86-64 swiftc 4.0.3
x86-64 swiftc 4.1
x86-64 swiftc 4.1.1
x86-64 swiftc 4.1.2
x86-64 swiftc 4.2
x86-64 swiftc 5.0
x86-64 swiftc 5.1
x86-64 swiftc 5.10
x86-64 swiftc 5.2
x86-64 swiftc 5.3
x86-64 swiftc 5.4
x86-64 swiftc 5.5
x86-64 swiftc 5.6
x86-64 swiftc 5.7
x86-64 swiftc 5.8
x86-64 swiftc 5.9
x86-64 swiftc nightly
Options
Source code
/// Returns the ASCII value corresponding to the low nibble of `number`, encoded as hex. func ascii_getHexDigit(_ number: UInt8) -> UInt8 { let table: StaticString = "0123456789ABCDEF" return table.withUTF8Buffer { table in table[Int(number & 0x0F)] } } /// Returns the numerical value of a hex digit. func ascii_parseHexDigit(ascii: UInt8) -> UInt8 { let (index, underflow) = ascii.subtractingReportingOverflow(0x30) guard underflow == false else { return 99 } let table = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // numbers 0-9 99, 99, 99, 99, 99, 99, 99, // 7 invalid chars from ':' to '@' 10, 11, 12, 13, 14, 15, // uppercase A-F 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, // 20 invalid chars G-Z 99, 99, 99, 99, 99, 99, // 6 invalid chars from '[' to '`' 10, 11, 12, 13, 14, 15, // lowercase a-f 99 as UInt8 ] guard index < table.count else { return 99 } return table[Int(index)] } let __table = ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // numbers 0-9 99, 99, 99, 99, 99, 99, 99, // 7 invalid chars from ':' to '@' 10, 11, 12, 13, 14, 15, // uppercase A-F 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, // 20 invalid chars G-Z 99, 99, 99, 99, 99, 99, // 6 invalid chars from '[' to '`' 10, 11, 12, 13, 14, 15 // lowercase a-f ) as (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8 ) func ascii_parseHexDigit2(ascii: UInt8) -> UInt8 { let (index, underflow) = ascii.subtractingReportingOverflow(0x30) guard underflow == false else { return 99 } guard index < 55 else { return 99 } return withUnsafeBytes(of: __table) { ptr in ptr[Int(index)] } }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
About the author
Statistics
Changelog
Version tree