From 67a149da6a3dcfd335d10bb026d85e5e91684db2 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Mon, 13 Feb 2023 10:55:51 -0800 Subject: [PATCH] _BString: Set better max node size in Release builds Also, adjust minimum node size calculation to match classic B-trees. --- Sources/RopeModule/BString/Basics/_BString+Summary.swift | 8 +++++++- Sources/RopeModule/Rope/Basics/_RopeSummary.swift | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/RopeModule/BString/Basics/_BString+Summary.swift b/Sources/RopeModule/BString/Basics/_BString+Summary.swift index ce138a82..5e0a9305 100644 --- a/Sources/RopeModule/BString/Basics/_BString+Summary.swift +++ b/Sources/RopeModule/BString/Basics/_BString+Summary.swift @@ -47,7 +47,13 @@ extension _BString.Summary: CustomStringConvertible { @available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *) extension _BString.Summary: _RopeSummary { @inline(__always) - static var maxNodeSize: Int { 10 } + static var maxNodeSize: Int { + #if DEBUG + return 10 + #else + return 15 + #endif + } @inline(__always) static var nodeSizeBitWidth: Int { 4 } diff --git a/Sources/RopeModule/Rope/Basics/_RopeSummary.swift b/Sources/RopeModule/Rope/Basics/_RopeSummary.swift index 4af962b2..d67f239f 100644 --- a/Sources/RopeModule/Rope/Basics/_RopeSummary.swift +++ b/Sources/RopeModule/Rope/Basics/_RopeSummary.swift @@ -37,7 +37,7 @@ protocol _RopeSummary: Equatable, Sendable { extension _RopeSummary { @inline(__always) - static var minNodeSize: Int { maxNodeSize / 2 } + static var minNodeSize: Int { (maxNodeSize + 1) / 2 } } extension _RopeSummary {