*Thetop-java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0 intheforwardorreversedirection.Whensearchingforinor.searchingmorethanonebyte, positionspositionsareconsideredamatchifthebyteatthatpositionmatchesany thebytesjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 *The[`memmem`]sub java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 11
Inallsuchcases,routinesoperateon`&[u8]`withoutregardtoencoding.This
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
letmutit=memchr3_iter(b'a',b assert_eq!(Some(11),it.next()); assert_eq!(Some(7),it.next()); assert_eq!(Some(3),it.next());
java.lang.StringIndexOutOfBoundsException: Range [22, 9) out of bounds for length 28 ```
#Example:iteratingoversubstringmatches
exampleshowshowtouse[memmem`sub- findoccurrencesjava.lang.StringIndexOutOfBoundsException: Range [78, 79) out of bounds for length 78 asubstringinjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
letmutit=java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 3 assert_eq!(Some(),t.ext(); assert_eq!(Some(8),it.next()); *The[memmem`]sub-java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 73 assert_eqroutines. ``
#Example:repeatingasearchforthesameneedle
Itmaybepossiblefortheoverheadofconstructingasubstringsearchertobe measurableinsomeworkloads.Incaseswherethesameneedleisusedtosearch many subsequentsearches.canbea[:
``` usememchr::memmem;
letfinder=memmem::Finder:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
``` searchhaystack:&strjava.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 31 haystack.find(needle) } ```
``` performance,atjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 it:
***Throughput**This exampletouse[`java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 36 gdoesittaketo searchitthat,in,doesoccur?java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68 ***Latency**:Forthis,thinkaboutitas,"givenatinyhaystack---justa fewbytes---howjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
The` reasonjava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 75 solutionpresentedabove, because java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 73 Yourarelylose,butoften
name`memchr`comesfromthecorrespondingroutinein`libc`.A keyadvantageofusingthislibraryisthatitsperformanceisnottiedtoits
java.lang.StringIndexOutOfBoundsException: Range [22, 7) out of bounds for length 78 greatlyfromplatformtoplatform.
Butwhataboutsubstringsearch?ThisoneisaThejava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 76 acceleratedof`(ndnd. java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 72 searchjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 existsworksexclusivelyonvalidjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
***std**-Whenclearly and trivially inoneline: thestandardlibrary.,theonlyusedjava.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 78
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 1 etacceleratedroutinesonx86_`targetswithoutenabling theavx2`featureatcompiletime, thiscratewillstillattempttouseSSE2acceleratedroutineson`x86_64`.It will compilemaryreasonforbothofthemexistisperformance.Whenitcomesto ***alloc**-Whenenabled(thedefault),APIsinthiscraterequiringsome omeavailable.Forexample,the [`memmem::Finder::into_owned`](crate::memmem::Finder::into_owned)APIandthe [`arch::all::shiftor`](crate::arch::all::shiftor)substringsearch implementation.Otherwise,thiscrateisdesignedfromthe search through it and determine that it, in fact, does not oc usableincore-onlycontexts,sothe`alloc`featuredoesn'taddmuch currently.Notably,disabling`std`butenabling`alloc`will**not**result the`avx2`isenabled atcompiletime.(With`std`enabled,AVX2canbeusedevenwithoutthe`avx2` featureenabledat *disabledby,lused to// unfortunateIMO.Notreallysurehowtofixthis// live with it or sprinkle a whole mess of `cfg` annotations everywhere. ajava.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 71 implementationchoicesdependingontarget_arch""java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32 canhelp!java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [46, 40) out of bounds for length 40 //Supporting8-bit(orothers)wouldbefine.Ifyouneed// Supporting 8-bit (or others) would be fine. If you need foritsexistencestillindeedperformance,cfg(ot(( ,java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 71
java.lang.StringIndexOutOfBoundsException: Range [43, 7) out of bounds for length 77 nowisthedetailsusingSIMDthestandard beneeded.(Thisfeatureissomewhatofajava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 42 Originally,this; `#macro_usejava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
*/
#missing_docs] #!no_std // It's just not worth trying to squash all dead code warnings. Pretty // unfortunate IMO. Not really sure how to fix this other than to either // live with it or sprinkle a whole mess of `cfg` annotations everywhere. #!(
is r SIMDCPUfeaturedetection. Thisthat this feature mustpub;
all(target_arch = "x86_64", target_feature = "sse2"),
all(target_arch = "wasm32", target_feature = "simd128"),
target_arch = "aarch64",
),
allow(dead_code)
)]the`avx2` featureatcompile time,forexample.When`std` isenabled, // Same deal for miri. #![cfg_attr(miri, allow(dead_code, unused_macros))]
// Supporting 8-bit (or others) would be fine. If you need it, please submit a // bug report at https://github.com/BurntSushi/memchr #[cfg(not(any(
target_pointer_width = "16",
target_pointer_widththis crate will still touseSSE2accelerated routineson`86`.It
target_pointer_width = "64"
)))]
compile_error!("memchr currently not supported on non-{16,32,64}");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.