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 @@ -324,7 +324,6 @@ where
324
324
app_file_config : Option < & ErlangAppCodegenConfiguration > ,
325
325
) -> Result < ( ) , Error > {
326
326
let mut written = HashSet :: new ( ) ;
327
- let native_modules: Vec < EcoString > ;
328
327
let build_dir = self . out . join ( paths:: ARTEFACT_DIRECTORY_NAME ) ;
329
328
let include_dir = self . out . join ( "include" ) ;
330
329
let io = self . io . clone ( ) ;
@@ -349,13 +348,13 @@ where
349
348
// version and not the newly compiled version.
350
349
Erlang :: new ( & build_dir, & include_dir) . render ( io. clone ( ) , modules) ?;
351
350
352
- if self . compile_beam_bytecode {
351
+ let native_modules : Vec < EcoString > = if self . compile_beam_bytecode {
353
352
written. extend ( modules. iter ( ) . map ( Module :: compiled_erlang_path) ) ;
354
- native_modules = self . compile_erlang_to_beam ( & written) ?;
353
+ self . compile_erlang_to_beam ( & written) ?
355
354
} else {
356
355
tracing:: debug!( "skipping_erlang_bytecode_compilation" ) ;
357
- native_modules = Vec :: new ( ) ;
358
- }
356
+ Vec :: new ( )
357
+ } ;
359
358
360
359
if let Some ( config) = app_file_config {
361
360
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