@@ -70,11 +70,11 @@ pub fn host_options() -> Result<OptionMap> {
7070 } ;
7171
7272 if let Some ( id) = info. id {
73- opts. insert ( OptName :: distro ( ) . to_owned ( ) , id. clone ( ) ) ;
73+ opts. insert ( OptName :: distro ( ) . to_owned ( ) , id. clone ( ) . into ( ) ) ;
7474 match OptNameBuf :: try_from ( id) {
7575 Ok ( id) => {
7676 if let Some ( version_id) = info. version_id {
77- opts. insert ( id, version_id) ;
77+ opts. insert ( id, version_id. into ( ) ) ;
7878 }
7979 }
8080 Err ( err) => {
@@ -90,11 +90,11 @@ pub fn host_options() -> Result<OptionMap> {
9090#[ derive( Default , Clone , Hash , PartialEq , Eq , Serialize , Ord , PartialOrd ) ]
9191#[ serde( transparent) ]
9292pub struct OptionMap {
93- options : BTreeMap < OptNameBuf , String > ,
93+ options : BTreeMap < OptNameBuf , Arc < str > > ,
9494}
9595
9696impl std:: ops:: Deref for OptionMap {
97- type Target = BTreeMap < OptNameBuf , String > ;
97+ type Target = BTreeMap < OptNameBuf , Arc < str > > ;
9898
9999 fn deref ( & self ) -> & Self :: Target {
100100 & self . options
@@ -107,16 +107,16 @@ impl std::ops::DerefMut for OptionMap {
107107 }
108108}
109109
110- impl From < & Arc < BTreeMap < OptNameBuf , String > > > for OptionMap {
111- fn from ( hm : & Arc < BTreeMap < OptNameBuf , String > > ) -> Self {
110+ impl From < & Arc < BTreeMap < OptNameBuf , Arc < str > > > > for OptionMap {
111+ fn from ( hm : & Arc < BTreeMap < OptNameBuf , Arc < str > > > ) -> Self {
112112 Self {
113113 options : ( * * hm) . clone ( ) ,
114114 }
115115 }
116116}
117117
118- impl FromIterator < ( OptNameBuf , String ) > for OptionMap {
119- fn from_iter < T : IntoIterator < Item = ( OptNameBuf , String ) > > ( iter : T ) -> Self {
118+ impl FromIterator < ( OptNameBuf , Arc < str > ) > for OptionMap {
119+ fn from_iter < T : IntoIterator < Item = ( OptNameBuf , Arc < str > ) > > ( iter : T ) -> Self {
120120 Self {
121121 options : BTreeMap :: from_iter ( iter) ,
122122 }
@@ -137,8 +137,8 @@ impl std::fmt::Display for OptionMap {
137137}
138138
139139impl IntoIterator for OptionMap {
140- type IntoIter = std:: collections:: btree_map:: IntoIter < OptNameBuf , String > ;
141- type Item = ( OptNameBuf , String ) ;
140+ type IntoIter = std:: collections:: btree_map:: IntoIter < OptNameBuf , Arc < str > > ;
141+ type Item = ( OptNameBuf , Arc < str > ) ;
142142
143143 fn into_iter ( self ) -> Self :: IntoIter {
144144 self . options . into_iter ( )
@@ -147,16 +147,16 @@ impl IntoIterator for OptionMap {
147147
148148impl OptionMap {
149149 /// Return the data of these options as environment variables.
150- pub fn to_environment ( & self ) -> HashMap < String , String > {
150+ pub fn to_environment ( & self ) -> HashMap < Arc < str > , Arc < str > > {
151151 let mut out = HashMap :: default ( ) ;
152152 for ( name, value) in self . iter ( ) {
153153 let var_name = format ! ( "SPK_OPT_{name}" ) ;
154- out. insert ( var_name, value . into ( ) ) ;
154+ out. insert ( var_name. into ( ) , Arc :: clone ( value ) ) ;
155155 }
156156 out
157157 }
158158
159- fn items ( & self ) -> Vec < ( OptNameBuf , String ) > {
159+ fn items ( & self ) -> Vec < ( OptNameBuf , Arc < str > ) > {
160160 self . options
161161 . iter ( )
162162 . map ( |( k, v) | ( k. to_owned ( ) , v. to_owned ( ) ) )
@@ -278,7 +278,7 @@ impl<'de> Deserialize<'de> for OptionMap {
278278 {
279279 let mut options = OptionMap :: default ( ) ;
280280 while let Some ( ( name, value) ) = map. next_entry :: < OptNameBuf , Stringified > ( ) ? {
281- options. insert ( name, value. 0 ) ;
281+ options. insert ( name, value. 0 . into ( ) ) ;
282282 }
283283 Ok ( options)
284284 }
0 commit comments