MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / hash_string_contents_with_config

Function hash_string_contents_with_config

src/engine.rs:826–847  ·  view source on GitHub ↗
(
    text: &str,
    config: &TextConfig,
)

Source from the content-addressed store, hash-verified

824}
825
826fn hash_string_contents_with_config(
827 text: &str,
828 config: &TextConfig,
829) -> u32 {
830 let mut hash: u32 = (hash_data_scalar(text.as_bytes()) % u32::MAX as u64) as u32;
831 // Fold in font key bytes
832 for &b in config.font_asset.map(|a| a.key()).unwrap_or("").as_bytes() {
833 hash = hash.wrapping_add(b as u32);
834 hash = hash.wrapping_add(hash << 10);
835 hash ^= hash >> 6;
836 }
837 hash = hash.wrapping_add(config.font_size as u32);
838 hash = hash.wrapping_add(hash << 10);
839 hash ^= hash >> 6;
840 hash = hash.wrapping_add(config.letter_spacing as u32);
841 hash = hash.wrapping_add(hash << 10);
842 hash ^= hash >> 6;
843 hash = hash.wrapping_add(hash << 3);
844 hash ^= hash >> 11;
845 hash = hash.wrapping_add(hash << 15);
846 hash.wrapping_add(1)
847}
848
849fn float_equal(left: f32, right: f32) -> bool {
850 let diff = left - right;

Callers 1

measure_text_cachedMethod · 0.85

Calls 2

hash_data_scalarFunction · 0.85
keyMethod · 0.80

Tested by

no test coverage detected