Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
permissions:
contents: read
runs-on: ubuntu-latest
container: swift:6.2-noble
container: swift:6.3-noble
steps:
- name: Check out sql-kit
uses: actions/checkout@v6
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
strategy:
fail-fast: false
matrix:
swift-image: ['swift:6.2-noble']
swift-image: ['swift:6.3-noble']
driver:
- { sqlkit: 'sqlite-kit', fluent: 'fluent-sqlite-driver' }
- { sqlkit: 'mysql-kit', fluent: 'fluent-mysql-driver' }
Expand Down
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:6.0
// swift-tools-version:6.1
import PackageDescription

let package = Package(
Expand Down Expand Up @@ -38,6 +38,8 @@ let package = Package(
.testTarget(
name: "SQLKitTests",
dependencies: [
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOEmbedded", package: "swift-nio"),
.target(name: "SQLKit"),
.target(name: "SQLKitBenchmark"),
],
Expand All @@ -48,7 +50,7 @@ let package = Package(

var swiftSettings: [SwiftSetting] { [
.enableUpcomingFeature("ExistentialAny"),
// .enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("MemberImportVisibility"),
.enableUpcomingFeature("InferIsolatedConformances"),
// .enableUpcomingFeature("NonisolatedNonsendingByDefault"),
Expand Down
15 changes: 9 additions & 6 deletions Sources/SQLKit/Docs.docc/theme-settings.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"theme": {
"aside": { "border-radius": "16px", "border-width": "3px", "border-style": "double" },
"border-radius": "0",
"aside": { "border-radius": "16px", "border-width": "3px", "border-style": "double" },
"button": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
"code": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
"color": {
"sqlkit": { "dark": "hsl(32, 77%, 63%)", "light": "hsl(32, 80%, 60%)" },
"documentation-intro-fill": "radial-gradient(circle at top, var(--color-sqlkit) 30%, #000 100%)",
"sqlkit": {
"dark": "hsl(32, 77%, 63%)",
"light": "hsl(32, 80%, 60%)"
},
"documentation-intro-fill": {
"dark": "radial-gradient(circle at top, var(--color-sqlkit) 0%, #000000 100%)",
"light": "radial-gradient(circle at top, var(--color-sqlkit) 0%, #f0f0f0 100%)"
},
"documentation-intro-accent": "var(--color-sqlkit)",
"hero-eyebrow": "white",
"documentation-intro-figure": "white",
"hero-title": "white",
"logo-base": { "dark": "#fff", "light": "#000" },
"logo-shape": { "dark": "#000", "light": "#fff" },
"fill": { "dark": "#000", "light": "#fff" }
Expand Down
22 changes: 13 additions & 9 deletions Sources/SQLKit/Utilities/StringHandling.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
extension StringProtocol where Self: RangeReplaceableCollection, Self.Element: Equatable {
/// Provides a version of `StringProtocol.firstRange(of:)` which is guaranteed to be available on
/// pre-Ventura Apple platforms.
/// Provides a version of `StringProtocol.firstRange(of:)` guaranteed to be available.
@inlinable
func sqlkit_firstRange(of other: some StringProtocol) -> Range<Self.Index>? {
/// N.B.: This implementation is apparently some 650% faster than `firstRange(of:)`, at least on macOS...
guard self.count >= other.count, let starter = other.first else { return nil }
var index = self.startIndex
let lastIndex = self.index(self.endIndex, offsetBy: -other.count)
Expand All @@ -21,15 +19,17 @@ extension StringProtocol where Self: RangeReplaceableCollection, Self.Element: E
return nil
}

/// Provides a version of `StringProtocol.replacing(_:with:)` which is guaranteed to be available on
/// pre-Ventura Apple platforms.
/// Provides a version of `StringProtocol.replacing(_:with:)` which is guaranteed to be available.
#if !DEBUG && !canImport(Darwin)
@inline(__always)
#endif
@inlinable
func sqlkit_replacing(_ search: some StringProtocol, with replacement: some StringProtocol) -> String {
/// N.B.: Even on Ventura/Sonoma, the handwritten implementation is orders of magnitude faster than
/// `replacing(_:with:)`, at least as of the time of this writing. Thus we use the handwritten version
/// unconditionally. It's still 4x slower than Foundation's version, but that's a lot better than 25x.
#if DEBUG || canImport(Darwin)
// On Apple platforms, this hand-rolled implementation is MUCH faster (10x or more) than the stdlib version, for some reason.
// We also want to use this implementation in debug builds, so that the tests test it rather than the stdlib.
guard !self.isEmpty, !search.isEmpty, self.count >= search.count else { return .init(self) }

var result = "", prevIndex = self.startIndex

result.reserveCapacity(self.count + replacement.count)
Expand All @@ -40,6 +40,10 @@ extension StringProtocol where Self: RangeReplaceableCollection, Self.Element: E
}
result.append(contentsOf: self[prevIndex...])
return result
#else
// On non-Apple platforms, the stdlib's version is better than our hand-rolled one.
return String(self.replacing(search, with: replacement))
#endif
}

/// Returns the string with its first character lowercased.
Expand Down
2 changes: 1 addition & 1 deletion Sources/SQLKitBenchmark/SQLBenchmarker.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Logging
import NIOCore
import SQLKit
public import SQLKit
import XCTest

public final class SQLBenchmarker: Sendable {
Expand Down
Loading
Loading