Skip to content

Commit b619843

Browse files
authored
fix: String regressions (#10523)
This PR fixes some regressions introduced by #10304.
1 parent 1374445 commit b619843

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

src/Init/Data/ByteArray/Basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def copySlice (src : @& ByteArray) (srcOff : Nat) (dest : ByteArray) (destOff le
8787
def extract (a : ByteArray) (b e : Nat) : ByteArray :=
8888
a.copySlice b empty 0 (e - b)
8989

90+
@[inline]
9091
protected def fastAppend (a : ByteArray) (b : ByteArray) : ByteArray :=
9192
-- we assume that `append`s may be repeated, so use asymptotic growing; use `copySlice` directly to customize
9293
b.copySlice 0 a a.size b.size false

src/Init/Data/String/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Examples:
160160
* `"" ++ "" = ""`
161161
-/
162162
@[extern "lean_string_append", expose]
163-
def String.append (s t : String) : String where
163+
def String.append (s : String) (t : @& String) : String where
164164
bytes := s.bytes ++ t.bytes
165165
isValidUtf8 := s.isValidUtf8.append t.isValidUtf8
166166

@@ -221,7 +221,7 @@ Examples:
221221
* `"L∃∀N".length = 4`
222222
-/
223223
@[extern "lean_string_length"]
224-
def String.length (b : String) : Nat :=
224+
def String.length (b : @& String) : Nat :=
225225
b.data.length
226226

227227
@[simp]

src/Init/Data/String/Bootstrap.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Examples:
141141
* `[].asString = ""`
142142
* `['a', 'a', 'a'].asString = "aaa"`
143143
-/
144-
@[expose]
144+
@[expose, inline]
145145
def List.asString (s : List Char) : String :=
146146
String.mk s
147147

src/Init/Data/String/Decode.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,7 @@ public theorem ByteArray.isSome_utf8DecodeChar?_append {b : ByteArray} {i : Nat}
11771177
obtain ⟨c, hc⟩ := Option.isSome_iff_exists.1 h
11781178
rw [utf8DecodeChar?_append_eq_some hc, Option.isSome_some]
11791179

1180+
@[inline]
11801181
public def ByteArray.utf8DecodeChar (bytes : ByteArray) (i : Nat) (h : (utf8DecodeChar? bytes i).isSome) : Char :=
11811182
(utf8DecodeChar? bytes i).get h
11821183

0 commit comments

Comments
 (0)