Skip to content

Commit 6d3e76a

Browse files
committed
Port slow_make_string
1 parent 04d5878 commit 6d3e76a

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

crates/engine_xetex/src/c_api/pool.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,29 @@ pub fn rs_make_string(pool: &mut StringPool) -> StrNumber {
154154
(pool.str_ptr - 1) as StrNumber
155155
}
156156

157+
pub fn rs_slow_make_string(pool: &mut StringPool) -> StrNumber {
158+
let t = rs_make_string(pool);
159+
let s = rs_search_string(pool, t);
160+
161+
if s > 0 {
162+
pool.str_ptr -= 1;
163+
pool.pool_ptr = pool.str_start[pool.str_ptr - TOO_BIG_CHAR] as usize;
164+
s
165+
} else {
166+
t
167+
}
168+
}
169+
157170
#[no_mangle]
158171
pub extern "C" fn make_string() -> StrNumber {
159172
STRING_POOL.with_borrow_mut(rs_make_string)
160173
}
161174

175+
#[no_mangle]
176+
pub extern "C" fn slow_make_string() -> StrNumber {
177+
STRING_POOL.with_borrow_mut(|pool| rs_slow_make_string(pool))
178+
}
179+
162180
pub fn rs_str_length(pool: &StringPool, s: StrNumber) -> usize {
163181
if s >= 0x10000 {
164182
pool.str(s - 0x10000).len()

crates/engine_xetex/xetex/xetex-stringpool.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,3 @@ str_eq_buf(str_number s, int32_t k)
8888

8989
return true;
9090
}
91-
92-
str_number
93-
slow_make_string(void)
94-
{
95-
str_number s;
96-
str_number t;
97-
98-
t = make_string();
99-
s = search_string(t);
100-
101-
if (s > 0) {
102-
set_str_ptr(str_ptr()-1);
103-
set_pool_ptr(str_start(str_ptr() - TOO_BIG_CHAR));
104-
return s;
105-
}
106-
107-
return t;
108-
}

crates/engine_xetex/xetex/xetex_bindings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ void set_max_strings(uintptr_t val);
449449

450450
StrNumber make_string(void);
451451

452+
StrNumber slow_make_string(void);
453+
452454
uintptr_t length(StrNumber s);
453455

454456
bool str_eq_str(StrNumber s1, StrNumber s2);

0 commit comments

Comments
 (0)