Skip to content

Commit 0376c54

Browse files
authored
Use icu crates instead of caseless/unicode_normalization in places (#7115)
I don't fully understand why we can't just `starts_with`, but I didn't dig too deep and left the core logic alone.
1 parent 24d3b29 commit 0376c54

File tree

7 files changed

+9
-160
lines changed

7 files changed

+9
-160
lines changed

Cargo.lock

Lines changed: 1 addition & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DEPENDENCIES.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ the details of which are reproduced below.
1111
* [MIT License: bincode](#mit-license-bincode)
1212
* [MIT License: bytes](#mit-license-bytes)
1313
* [MIT License: cargo_metadata, winnow](#mit-license-cargo_metadata-winnow)
14-
* [MIT License: caseless](#mit-license-caseless)
1514
* [MIT License: core_maths](#mit-license-core_maths)
1615
* [MIT License: extend](#mit-license-extend)
1716
* [MIT License: generic-array](#mit-license-generic-array)
@@ -582,11 +581,8 @@ The following text applies to code linked from these dependencies:
582581
[thiserror-impl](https://github.com/dtolnay/thiserror),
583582
[thiserror](https://github.com/dtolnay/thiserror),
584583
[thread_local](https://github.com/Amanieu/thread_local-rs),
585-
[tinyvec](https://github.com/Lokathor/tinyvec),
586-
[tinyvec_macros](https://github.com/Soveu/tinyvec_macros),
587584
[toml](https://github.com/alexcrichton/toml-rs),
588585
[typenum](https://github.com/paholg/typenum),
589-
[unicode-normalization](https://github.com/unicode-rs/unicode-normalization),
590586
[url](https://github.com/servo/rust-url),
591587
[utf8_iter](https://github.com/hsivonen/utf8_iter),
592588
[uuid](https://github.com/uuid-rs/uuid),
@@ -963,37 +959,6 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
963959
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
964960
DEALINGS IN THE SOFTWARE.
965961
966-
```
967-
-------------
968-
## MIT License: caseless
969-
970-
The following text applies to code linked from these dependencies:
971-
[caseless](https://github.com/SimonSapin/rust-caseless)
972-
973-
```
974-
Copyright (c) 2017 Simon Sapin
975-
976-
MIT License
977-
978-
Permission is hereby granted, free of charge, to any person obtaining
979-
a copy of this software and associated documentation files (the
980-
"Software"), to deal in the Software without restriction, including
981-
without limitation the rights to use, copy, modify, merge, publish,
982-
distribute, sublicense, and/or sell copies of the Software, and to
983-
permit persons to whom the Software is furnished to do so, subject to
984-
the following conditions:
985-
986-
The above copyright notice and this permission notice shall be
987-
included in all copies or substantial portions of the Software.
988-
989-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
990-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
991-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
992-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
993-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
994-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
995-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
996-
997962
```
998963
-------------
999964
## MIT License: core_maths

components/places/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ parking_lot = "0.12"
2020
lazy_static = "1.4"
2121
url = { version = "2.1", features = ["serde"] }
2222
percent-encoding = "2.1"
23-
caseless = "0.2"
23+
icu_casemap = "2"
2424
rusqlite = { version = "0.37.0", features = ["functions", "window", "bundled", "unlock_notify"] }
2525
sql-support = { path = "../support/sql" }
2626
types = { path = "../support/types" }

components/places/src/match_impl.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use crate::util;
66
use bitflags::bitflags;
7-
use caseless::Caseless;
7+
use icu_casemap::CaseMapperBorrowed;
88
use rusqlite::{
99
self,
1010
types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef},
@@ -13,6 +13,8 @@ use std::borrow::Cow;
1313

1414
const MAX_CHARS_TO_SEARCH_THROUGH: usize = 255;
1515

16+
static CASE_MAPPER: CaseMapperBorrowed<'_> = CaseMapperBorrowed::new();
17+
1618
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
1719
#[repr(u32)]
1820
pub enum MatchBehavior {
@@ -225,8 +227,10 @@ fn string_match(token: &str, source: &str) -> bool {
225227
if source.len() < token.len() {
226228
return false;
227229
}
228-
let mut ti = token.chars().default_case_fold();
229-
let mut si = source.chars().default_case_fold();
230+
let t_folded = CASE_MAPPER.fold_string(token);
231+
let mut ti = t_folded.chars();
232+
let s_folded = CASE_MAPPER.fold_string(source);
233+
let mut si = s_folded.chars();
230234
loop {
231235
match (ti.next(), si.next()) {
232236
(None, _) => return true,

megazords/full/DEPENDENCIES.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ the details of which are reproduced below.
1010
* [MIT License: bincode](#mit-license-bincode)
1111
* [MIT License: bytes](#mit-license-bytes)
1212
* [MIT License: cargo_metadata, winnow](#mit-license-cargo_metadata-winnow)
13-
* [MIT License: caseless](#mit-license-caseless)
1413
* [MIT License: core_maths](#mit-license-core_maths)
1514
* [MIT License: extend](#mit-license-extend)
1615
* [MIT License: generic-array](#mit-license-generic-array)
@@ -532,11 +531,8 @@ The following text applies to code linked from these dependencies:
532531
[thiserror-impl](https://github.com/dtolnay/thiserror),
533532
[thiserror](https://github.com/dtolnay/thiserror),
534533
[thread_local](https://github.com/Amanieu/thread_local-rs),
535-
[tinyvec](https://github.com/Lokathor/tinyvec),
536-
[tinyvec_macros](https://github.com/Soveu/tinyvec_macros),
537534
[toml](https://github.com/alexcrichton/toml-rs),
538535
[typenum](https://github.com/paholg/typenum),
539-
[unicode-normalization](https://github.com/unicode-rs/unicode-normalization),
540536
[url](https://github.com/servo/rust-url),
541537
[utf8_iter](https://github.com/hsivonen/utf8_iter),
542538
[uuid](https://github.com/uuid-rs/uuid),
@@ -880,37 +876,6 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
880876
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
881877
DEALINGS IN THE SOFTWARE.
882878
883-
```
884-
-------------
885-
## MIT License: caseless
886-
887-
The following text applies to code linked from these dependencies:
888-
[caseless](https://github.com/SimonSapin/rust-caseless)
889-
890-
```
891-
Copyright (c) 2017 Simon Sapin
892-
893-
MIT License
894-
895-
Permission is hereby granted, free of charge, to any person obtaining
896-
a copy of this software and associated documentation files (the
897-
"Software"), to deal in the Software without restriction, including
898-
without limitation the rights to use, copy, modify, merge, publish,
899-
distribute, sublicense, and/or sell copies of the Software, and to
900-
permit persons to whom the Software is furnished to do so, subject to
901-
the following conditions:
902-
903-
The above copyright notice and this permission notice shall be
904-
included in all copies or substantial portions of the Software.
905-
906-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
907-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
908-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
909-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
910-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
911-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
912-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
913-
914879
```
915880
-------------
916881
## MIT License: core_maths

megazords/full/android/dependency-licenses.xml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,6 @@ the details of which are reproduced below.
456456
<name>Apache License 2.0: thread_local</name>
457457
<url>https://github.com/Amanieu/thread_local-rs/blob/master/LICENSE-APACHE</url>
458458
</license>
459-
<license>
460-
<name>Apache License 2.0: tinyvec</name>
461-
<url>https://github.com/Lokathor/tinyvec/blob/main/LICENSE-ZLIB.md</url>
462-
</license>
463-
<license>
464-
<name>Apache License 2.0: tinyvec_macros</name>
465-
<url>https://github.com/Soveu/tinyvec_macros/blob/master/LICENSE-APACHE.md</url>
466-
</license>
467459
<license>
468460
<name>Apache License 2.0: toml</name>
469461
<url>https://github.com/alexcrichton/toml-rs/blob/master/LICENSE-APACHE</url>
@@ -472,10 +464,6 @@ the details of which are reproduced below.
472464
<name>Apache License 2.0: typenum</name>
473465
<url>https://github.com/paholg/typenum/blob/main/LICENSE-APACHE</url>
474466
</license>
475-
<license>
476-
<name>Apache License 2.0: unicode-normalization</name>
477-
<url>https://github.com/unicode-rs/unicode-normalization/blob/master/LICENSE-APACHE</url>
478-
</license>
479467
<license>
480468
<name>Apache License 2.0: url</name>
481469
<url>https://github.com/servo/rust-url/blob/main/LICENSE-APACHE</url>
@@ -544,10 +532,6 @@ the details of which are reproduced below.
544532
<name>MIT License: winnow</name>
545533
<url>https://github.com/winnow-rs/winnow/blob/main/LICENSE-MIT</url>
546534
</license>
547-
<license>
548-
<name>MIT License: caseless</name>
549-
<url>https://github.com/SimonSapin/rust-caseless/blob/master/LICENSE</url>
550-
</license>
551535
<license>
552536
<name>MIT License: core_maths</name>
553537
<url>https://github.com/robertbastian/core_maths/blob/main/LICENSE</url>

megazords/ios-rust/DEPENDENCIES.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ the details of which are reproduced below.
1111
* [MIT License: bincode](#mit-license-bincode)
1212
* [MIT License: bytes](#mit-license-bytes)
1313
* [MIT License: cargo_metadata, winnow](#mit-license-cargo_metadata-winnow)
14-
* [MIT License: caseless](#mit-license-caseless)
1514
* [MIT License: core_maths](#mit-license-core_maths)
1615
* [MIT License: extend](#mit-license-extend)
1716
* [MIT License: generic-array](#mit-license-generic-array)
@@ -567,11 +566,8 @@ The following text applies to code linked from these dependencies:
567566
[thiserror-impl](https://github.com/dtolnay/thiserror),
568567
[thiserror](https://github.com/dtolnay/thiserror),
569568
[thread_local](https://github.com/Amanieu/thread_local-rs),
570-
[tinyvec](https://github.com/Lokathor/tinyvec),
571-
[tinyvec_macros](https://github.com/Soveu/tinyvec_macros),
572569
[toml](https://github.com/alexcrichton/toml-rs),
573570
[typenum](https://github.com/paholg/typenum),
574-
[unicode-normalization](https://github.com/unicode-rs/unicode-normalization),
575571
[url](https://github.com/servo/rust-url),
576572
[utf8_iter](https://github.com/hsivonen/utf8_iter),
577573
[uuid](https://github.com/uuid-rs/uuid),
@@ -941,37 +937,6 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
941937
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
942938
DEALINGS IN THE SOFTWARE.
943939
944-
```
945-
-------------
946-
## MIT License: caseless
947-
948-
The following text applies to code linked from these dependencies:
949-
[caseless](https://github.com/SimonSapin/rust-caseless)
950-
951-
```
952-
Copyright (c) 2017 Simon Sapin
953-
954-
MIT License
955-
956-
Permission is hereby granted, free of charge, to any person obtaining
957-
a copy of this software and associated documentation files (the
958-
"Software"), to deal in the Software without restriction, including
959-
without limitation the rights to use, copy, modify, merge, publish,
960-
distribute, sublicense, and/or sell copies of the Software, and to
961-
permit persons to whom the Software is furnished to do so, subject to
962-
the following conditions:
963-
964-
The above copyright notice and this permission notice shall be
965-
included in all copies or substantial portions of the Software.
966-
967-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
968-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
969-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
970-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
971-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
972-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
973-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
974-
975940
```
976941
-------------
977942
## MIT License: core_maths

0 commit comments

Comments
 (0)