@@ -105,20 +105,6 @@ typedef struct AK3MFBlendMethods {
105105 bool cached ;
106106} AK3MFBlendMethods ;
107107
108- static
109- bool
110- ak_3mf_slice_eq_cstr (const char * __restrict slice ,
111- size_t sliceLen ,
112- const char * __restrict str ) {
113- size_t len ;
114-
115- if (!slice || !str )
116- return false;
117-
118- len = strlen (str );
119- return len == sliceLen && memcmp (slice , str , len ) == 0 ;
120- }
121-
122108AK_INLINE
123109bool
124110ak_3mf_space (char c ) {
@@ -180,7 +166,8 @@ ak_3mf_cstr_ends_lit(const char * __restrict str,
180166 return false;
181167
182168 len = strlen (str );
183- return len >= litLen && memcmp (str + len - litLen , lit , litLen ) == 0 ;
169+ return len >= litLen
170+ && ak_str_eq_fast (str + len - litLen , litLen , lit , litLen );
184171}
185172
186173static
@@ -299,17 +286,7 @@ ak_3mf_entry_name_eq_sz(const char * __restrict name,
299286
300287 name = ak_3mf_skip_root_slash (name , & nameLen );
301288 path = ak_3mf_skip_root_slash (path , & pathLen );
302- return nameLen == pathLen && memcmp (name , path , nameLen ) == 0 ;
303- }
304-
305- static
306- bool
307- ak_3mf_entry_name_eq (const char * __restrict name ,
308- size_t nameLen ,
309- const char * __restrict path ) {
310- return path
311- ? ak_3mf_entry_name_eq_sz (name , nameLen , path , strlen (path ))
312- : false;
289+ return ak_str_eq_fast (name , nameLen , path , pathLen );
313290}
314291
315292static
@@ -341,7 +318,7 @@ ak_3mf_xmla_local_sz(const xml_t * __restrict xml,
341318 attrName = colon + 1u ;
342319 }
343320
344- if (attrNameLen == nameLen && memcmp (attrName , name , nameLen ) == 0 )
321+ if (ak_str_eq_fast (attrName , attrNameLen , name , nameLen ))
345322 return attr ;
346323 }
347324
@@ -389,7 +366,7 @@ ak_3mf_attr_value_eq_entry(const xml_attr_t * __restrict attr,
389366
390367 value = attr -> val ;
391368 valueLen = attr -> valsize ;
392- return ak_3mf_entry_name_eq (value , valueLen , entryName );
369+ return ak_3mf_entry_name_eq_sz (value , valueLen , entryName , strlen ( entryName ) );
393370}
394371
395372static
@@ -408,7 +385,7 @@ ak_3mf_model_path_eq(const char * __restrict a,
408385 bLen = strlen (b );
409386 a = ak_3mf_skip_root_slash (a , & aLen );
410387 b = ak_3mf_skip_root_slash (b , & bLen );
411- return aLen == bLen && memcmp (a , b , aLen ) == 0 ;
388+ return ak_str_eq_fast (a , aLen , b , bLen ) ;
412389}
413390
414391static
@@ -705,7 +682,7 @@ ak_3mf_tag_sz(const xml_t * __restrict xml,
705682 if (!tag || !ak_3mf_tag_local (xml , & xmlTag , & xmlTagSize ))
706683 return false;
707684
708- return tagSize == xmlTagSize && memcmp (xmlTag , tag , tagSize ) == 0 ;
685+ return ak_str_eq_fast (xmlTag , xmlTagSize , tag , tagSize );
709686}
710687
711688static
@@ -1250,6 +1227,9 @@ ak_3mf_content_type_dup(AkDoc * __restrict doc,
12501227
12511228 ext = ak_3mf_entry_extension (entryName );
12521229 if (ext ) {
1230+ size_t extLen ;
1231+
1232+ extLen = strlen (ext );
12531233 for (child = contentTypesRoot -> val ; child ; child = child -> next ) {
12541234 xml_attr_t * extension ;
12551235 xml_attr_t * contentType ;
@@ -1260,7 +1240,7 @@ ak_3mf_content_type_dup(AkDoc * __restrict doc,
12601240 extension = AK_3MF_XMLA (child , Extension );
12611241 if (!extension
12621242 || !extension -> val
1263- || !ak_3mf_slice_eq_cstr (extension -> val , extension -> valsize , ext ))
1243+ || !ak_str_eq_fast (extension -> val , extension -> valsize , ext , extLen ))
12641244 continue ;
12651245
12661246 contentType = AK_3MF_XMLA (child , ContentType );
@@ -1760,7 +1740,11 @@ ak_3mf_import_package_part_visitor(const AkZipEntryInfo * __restrict info,
17601740 return true;
17611741 if (AK_3MF_ENTRY_NAME_EQ (info -> name , info -> nameLen , AK_3MF_CONTENT_TYPES_PART )
17621742 || AK_3MF_ENTRY_NAME_EQ (info -> name , info -> nameLen , AK_3MF_ROOT_RELS_PART )
1763- || ak_3mf_entry_name_eq (info -> name , info -> nameLen , st -> modelPath ))
1743+ || (st -> modelPath
1744+ && ak_3mf_entry_name_eq_sz (info -> name ,
1745+ info -> nameLen ,
1746+ st -> modelPath ,
1747+ strlen (st -> modelPath ))))
17641748 return true;
17651749
17661750 entryName = malloc (info -> nameLen + 1u );
0 commit comments