mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-02-13 14:20:14 +08:00
Remove unsafes
This commit is contained in:
parent
246ad3b06e
commit
803a699b15
@ -1,7 +1,6 @@
|
|||||||
use std::fs::{read_dir, read_to_string, remove_file, File};
|
use std::fs::{read_dir, read_to_string, remove_file, File};
|
||||||
use std::io::{BufWriter, Write as _};
|
use std::io::{BufWriter, Write as _};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::ptr;
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use anyhow::{bail, Context};
|
use anyhow::{bail, Context};
|
||||||
@ -651,17 +650,12 @@ fn hair_dryer(
|
|||||||
.enumerate()
|
.enumerate()
|
||||||
{
|
{
|
||||||
let (key, value) = result?;
|
let (key, value) = result?;
|
||||||
count += key.len() + value.len();
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
// All of this just to avoid compiler optimizations 🤞
|
// All of this just to avoid compiler optimizations 🤞
|
||||||
// We must read all the bytes to make the pages hot in cache.
|
// We must read all the bytes to make the pages hot in cache.
|
||||||
// <https://doc.rust-lang.org/std/ptr/fn.read_volatile.html>
|
// <https://doc.rust-lang.org/std/hint/fn.black_box.html>
|
||||||
ptr::read_volatile(&key[0]);
|
count += std::hint::black_box(key.iter().fold(0, |acc, _| acc + 1));
|
||||||
ptr::read_volatile(&key[key.len() - 1]);
|
count += std::hint::black_box(value.iter().fold(0, |acc, _| acc + 1));
|
||||||
ptr::read_volatile(&value[0]);
|
|
||||||
ptr::read_volatile(&value[value.len() - 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if i % 10_000 == 0 {
|
if i % 10_000 == 0 {
|
||||||
let perc = (i as f64) / (total as f64) * 100.0;
|
let perc = (i as f64) / (total as f64) * 100.0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user