@@ -307,7 +307,7 @@ mod write {
307307 */
308308
309309fn build_link_meta ( sess : session , c : ast:: crate , output : ~str ,
310- sha : sha1 ) -> link_meta {
310+ symbol_hasher : hash :: streaming ) -> link_meta {
311311
312312 type provided_metas =
313313 { name : option < @~str > ,
@@ -338,7 +338,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
338338 }
339339
340340 // This calculates CMH as defined above
341- fn crate_meta_extras_hash ( sha : sha1 , _crate : ast:: crate ,
341+ fn crate_meta_extras_hash ( symbol_hasher : hash :: streaming , _crate : ast:: crate ,
342342 metas : provided_metas ,
343343 dep_hashes : ~[ @~str ] ) -> ~str {
344344 fn len_and_str ( s : ~str ) -> ~str {
@@ -351,15 +351,15 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
351351
352352 let cmh_items = attr:: sort_meta_items ( metas. cmh_items ) ;
353353
354- sha . reset ( ) ;
354+ symbol_hasher . reset ( ) ;
355355 for cmh_items. each |m_| {
356356 let m = m_;
357357 alt m. node {
358358 ast:: meta_name_value ( key, value) {
359- sha . input_str ( len_and_str ( * key) ) ;
360- sha . input_str ( len_and_str_lit ( value) ) ;
359+ symbol_hasher . input_str ( len_and_str ( * key) ) ;
360+ symbol_hasher . input_str ( len_and_str_lit ( value) ) ;
361361 }
362- ast:: meta_word ( name) { sha . input_str ( len_and_str ( * name) ) ; }
362+ ast:: meta_word ( name) { symbol_hasher . input_str ( len_and_str ( * name) ) ; }
363363 ast:: meta_list ( _, _) {
364364 // FIXME (#607): Implement this
365365 fail ~"unimplemented meta_item variant";
@@ -368,10 +368,10 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
368368 }
369369
370370 for dep_hashes. each |dh| {
371- sha . input_str ( len_and_str ( * dh) ) ;
371+ symbol_hasher . input_str ( len_and_str ( * dh) ) ;
372372 }
373373
374- ret truncated_sha1_result ( sha ) ;
374+ ret truncated_hash_result ( symbol_hasher ) ;
375375 }
376376
377377 fn warn_missing ( sess : session , name : ~str , default : ~str ) {
@@ -419,40 +419,40 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
419419 let vers = crate_meta_vers ( sess, c, provided_metas) ;
420420 let dep_hashes = cstore:: get_dep_hashes ( sess. cstore ) ;
421421 let extras_hash =
422- crate_meta_extras_hash ( sha , c, provided_metas, dep_hashes) ;
422+ crate_meta_extras_hash ( symbol_hasher , c, provided_metas, dep_hashes) ;
423423
424424 ret { name : name, vers : vers, extras_hash : extras_hash} ;
425425}
426426
427- fn truncated_sha1_result ( sha : sha1 ) -> ~str unsafe {
428- ret str :: slice ( sha . result_str ( ) , 0 u , 16 u ) ;
427+ fn truncated_hash_result ( symbol_hasher : hash :: streaming ) -> ~str unsafe {
428+ symbol_hasher . result_str ( )
429429}
430430
431431
432432// This calculates STH for a symbol, as defined above
433- fn symbol_hash ( tcx : ty:: ctxt , sha : sha1 , t : ty:: t ,
433+ fn symbol_hash ( tcx : ty:: ctxt , symbol_hasher : hash :: streaming , t : ty:: t ,
434434 link_meta : link_meta ) -> ~str {
435435 // NB: do *not* use abbrevs here as we want the symbol names
436436 // to be independent of one another in the crate.
437437
438- sha . reset ( ) ;
439- sha . input_str ( * link_meta. name ) ;
440- sha . input_str ( ~"-");
441- sha .input_str(link_meta.extras_hash);
442- sha .input_str(~" -");
443- sha .input_str(encoder::encoded_ty(tcx, t));
444- let hash = truncated_sha1_result(sha );
438+ symbol_hasher . reset ( ) ;
439+ symbol_hasher . input_str ( * link_meta. name ) ;
440+ symbol_hasher . input_str ( ~"-");
441+ symbol_hasher .input_str(link_meta.extras_hash);
442+ symbol_hasher .input_str(~" -");
443+ symbol_hasher .input_str(encoder::encoded_ty(tcx, t));
444+ let hash = truncated_hash_result(symbol_hasher );
445445 // Prefix with _ so that it never blends into adjacent digits
446446
447447 ret ~" _" + hash;
448448}
449449
450450fn get_symbol_hash ( ccx : @crate_ctxt , t : ty:: t ) -> ~str {
451- alt ccx. type_sha1s . find ( t) {
451+ alt ccx. type_hashcodes . find ( t) {
452452 some ( h) { ret h; }
453453 none {
454- let hash = symbol_hash ( ccx. tcx , ccx. sha , t, ccx. link_meta ) ;
455- ccx. type_sha1s . insert ( t, hash) ;
454+ let hash = symbol_hash ( ccx. tcx , ccx. symbol_hasher , t, ccx. link_meta ) ;
455+ ccx. type_hashcodes . insert ( t, hash) ;
456456 ret hash;
457457 }
458458 }
0 commit comments