File tree 2 files changed +14
-20
lines changed
2 files changed +14
-20
lines changed Original file line number Diff line number Diff line change @@ -328,7 +328,6 @@ where
328
328
app_file_config : Option < & ErlangAppCodegenConfiguration > ,
329
329
) -> Result < ( ) , Error > {
330
330
let mut written = HashSet :: new ( ) ;
331
- let native_modules: Vec < EcoString > ;
332
331
let build_dir = self . out . join ( paths:: ARTEFACT_DIRECTORY_NAME ) ;
333
332
let include_dir = self . out . join ( "include" ) ;
334
333
let io = self . io . clone ( ) ;
@@ -353,13 +352,13 @@ where
353
352
// version and not the newly compiled version.
354
353
Erlang :: new ( & build_dir, & include_dir) . render ( io. clone ( ) , modules) ?;
355
354
356
- if self . compile_beam_bytecode {
355
+ let native_modules : Vec < EcoString > = if self . compile_beam_bytecode {
357
356
written. extend ( modules. iter ( ) . map ( Module :: compiled_erlang_path) ) ;
358
- native_modules = self . compile_erlang_to_beam ( & written) ?;
357
+ self . compile_erlang_to_beam ( & written) ?
359
358
} else {
360
359
tracing:: debug!( "skipping_erlang_bytecode_compilation" ) ;
361
- native_modules = Vec :: new ( ) ;
362
- }
360
+ Vec :: new ( )
361
+ } ;
363
362
364
363
if let Some ( config) = app_file_config {
365
364
ErlangApp :: new ( & self . out . join ( "ebin" ) , config) . render (
Original file line number Diff line number Diff line change @@ -154,23 +154,18 @@ impl<'a> ErlangApp<'a> {
154
154
}
155
155
156
156
fn format_atom ( s : & EcoString ) -> EcoString {
157
- match s. chars ( ) . next ( ) {
158
- Some ( first_char) => {
159
- // Check if first character is not lowercase
160
- let needs_quotes = !first_char. is_ascii_lowercase ( ) ;
157
+ let mut chars = s. chars ( ) ;
161
158
162
- // Check if string contains any characters other than alphanumeric, underscore, or @
163
- let contains_special = s
164
- . chars ( )
165
- . any ( |c| !( c. is_alphanumeric ( ) || c == '_' || c == '@' ) ) ;
159
+ let Some ( first) = chars. next ( ) else {
160
+ return "''" . into ( ) ;
161
+ } ;
166
162
167
- if needs_quotes || contains_special {
168
- EcoString :: from ( format ! ( "'{}'" , s) )
169
- } else {
170
- s. clone ( )
171
- }
172
- }
173
- None => EcoString :: from ( "''" ) ,
163
+ let needs_escape = |c : char | !( c. is_alphanumeric ( ) || c == '_' || c == '@' ) ;
164
+
165
+ if !first. is_ascii_lowercase ( ) || chars. any ( needs_escape) {
166
+ format ! ( "'{}'" , s) . into ( )
167
+ } else {
168
+ s. clone ( )
174
169
}
175
170
}
176
171
}
You can’t perform that action at this time.
0 commit comments