Skip allocations
This commit is contained in:
parent
5e8587c39f
commit
81403960b0
1 changed files with 2 additions and 1 deletions
|
@ -6,6 +6,7 @@ use std::{
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
use tinyvec::TinyVec;
|
||||||
|
|
||||||
use crate::app::{
|
use crate::app::{
|
||||||
index::{
|
index::{
|
||||||
|
@ -136,7 +137,7 @@ struct TextFieldIndex {
|
||||||
impl TextFieldIndex {
|
impl TextFieldIndex {
|
||||||
pub fn insert(&mut self, raw_value: &str, value: Spur, key: SongKey) {
|
pub fn insert(&mut self, raw_value: &str, value: Spur, key: SongKey) {
|
||||||
// TODO sanitize ngrams
|
// TODO sanitize ngrams
|
||||||
let characters = raw_value.chars().collect::<Vec<_>>();
|
let characters = raw_value.chars().collect::<TinyVec<[char; 32]>>();
|
||||||
for substring in characters[..].windows(NGRAM_SIZE) {
|
for substring in characters[..].windows(NGRAM_SIZE) {
|
||||||
self.ngrams
|
self.ngrams
|
||||||
.entry(substring.try_into().unwrap())
|
.entry(substring.try_into().unwrap())
|
||||||
|
|
Loading…
Add table
Reference in a new issue