Skip to content

Commit c1bb76e

Browse files
committed
More fixes in orjson 3.10.18 patch
1 parent ee36da4 commit c1bb76e

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

graalpython/lib-graalpython/patches/orjson-3.10.18.patch

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
commit 121a88e014aba626f45c72baed02b32c7b125f07
1+
commit a889953c08d33854e574ab06e9593e0484c4c147
22
Author: stepan <[email protected]>
33
Date: Wed Jul 9 18:50:37 2025 +0200
44

@@ -683,7 +683,7 @@ index 4f1c76b..3d2c7e9 100644
683683
}
684684
}
685685
diff --git a/src/str/pyunicode_new.rs b/src/str/pyunicode_new.rs
686-
index 7b1c2df..0f21024 100644
686+
index 7b1c2df..5ac8dec 100644
687687
--- a/src/str/pyunicode_new.rs
688688
+++ b/src/str/pyunicode_new.rs
689689
@@ -1,75 +1,30 @@
@@ -765,14 +765,32 @@ index 7b1c2df..0f21024 100644
765765
- core::ptr::write(data_ptr, 0);
766766
- validate_str!(ptr);
767767
- ptr.cast::<PyObject>()
768-
+ PyUnicode_FromStringAndSize(buf.as_ptr() as *const i8, usize_to_isize(num_chars))
768+
+ PyUnicode_FromStringAndSize(buf.as_ptr() as *const i8, usize_to_isize(buf.len()))
769769
}
770770
}
771771
diff --git a/src/str/scalar.rs b/src/str/scalar.rs
772-
index 12adb63..c8e6a2e 100644
772+
index 12adb63..99fce8f 100644
773773
--- a/src/str/scalar.rs
774774
+++ b/src/str/scalar.rs
775-
@@ -40,7 +40,9 @@ pub fn str_impl_kind_scalar(buf: &str) -> *mut pyo3_ffi::PyObject {
775+
@@ -1,11 +1,17 @@
776+
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
777+
778+
+use pyo3_ffi::PyUnicode_FromStringAndSize;
779+
use crate::str::pyunicode_new::{
780+
pyunicode_ascii, pyunicode_fourbyte, pyunicode_onebyte, pyunicode_twobyte,
781+
};
782+
+use crate::util::usize_to_isize;
783+
784+
#[inline(never)]
785+
pub fn str_impl_kind_scalar(buf: &str) -> *mut pyo3_ffi::PyObject {
786+
+ // all the optimizations below don't make sense for GraalPy
787+
+ return unsafe {
788+
+ PyUnicode_FromStringAndSize(buf.as_ptr() as *const i8, usize_to_isize(buf.len()))
789+
+ };
790+
let num_chars = bytecount::num_chars(buf.as_bytes());
791+
if buf.len() == num_chars {
792+
return pyunicode_ascii(buf.as_ptr(), num_chars);
793+
@@ -40,7 +46,9 @@ pub fn str_impl_kind_scalar(buf: &str) -> *mut pyo3_ffi::PyObject {
776794
#[inline(always)]
777795
pub fn unicode_from_str(buf: &str) -> *mut pyo3_ffi::PyObject {
778796
if unlikely!(buf.is_empty()) {

0 commit comments

Comments
 (0)