Code quality improvements: style, performance, and documentation#41
Merged
Conversation
Style fixes: - switch_statement_parser: while true -> loop do - function_runtime: remove duplicate FUNCTION_NAME_REGEX, use .try(&.parameters.size) - interpreter: fix constant spacing, condense truthy?/strict_equals_values? guard clauses - expression_evaluator: condense truthy?/strict_equality_result guard clauses - giavascript_cli: break ternary into named variable, fix .ls -> .js in usage Performance improvements: - interpreter: single-pass String.build for escape_string (replaces chained .gsub) - runtime_types: Schwartzian transform for array_sort to avoid O(n log n) string conversions - runtime_types: in-place array_splice and array_unshift to reduce allocations - interpreter: bail-early in split_assignment_statement when no '=' present - interpreter: cache FallbackRawStatement results - interpreter: use String.build for value_to_s array/hash serialization - expression_parser: use Set for parameter duplicate detection (O(n) instead of O(n^2)) Documentation: - README: fix broken logo fallback, update examples list, improve CLI section - Language.md: document arrow functions, typeof semantics, unary plus, comments, semicolons, console.log - Math.md: add edge case notes for Math.max()/Math.min() - Types.md: fix grammar - CONTRIBUTING.md: clarify CI verification and improve wording - Add CHANGELOG.md, PR template, and issue templates Closes #40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Comprehensive code quality improvements across the GiavaScript codebase, covering Crystal code style, algorithm performance, and documentation. No functionality changes.
Style fixes (7 files)
switch_statement_parser.cr:while true→loop do(idiomatic Crystal)function_runtime.cr: Remove duplicateFUNCTION_NAME_REGEX(same asIDENTIFIER_REGEX), use.try(&.parameters.size)interpreter.cr: Fix constant spacing, condensetruthy?/strict_equals_values?guard clausesexpression_evaluator.cr: Same guard clause condensation for consistencygiavascript_cli.cr: Break ternary into named variable, fix.ls→.jsin usage messagePerformance improvements (5 files)
interpreter.cr: Single-passString.buildforescape_stringreplaces chained.gsub(4x fewer allocations)runtime_types.cr: Schwartzian transform forarray_sort— compute keys once instead of O(n log n) timesruntime_types.cr: In-placearray_spliceandarray_unshifteliminate full array copies (2-4x speedup)interpreter.cr: Bail-early insplit_assignment_statementwhen no=present (50-80% reduction for non-assignment statements)interpreter.cr: CacheFallbackRawStatementresults (avoids repeated compilation)interpreter.cr: UseString.buildforvalue_to_sarray/hash serialization (eliminates intermediate arrays)expression_parser.cr: UseSetfor parameter duplicate detection (O(n) vs O(n^2))Documentation updates (6 files)
README.md: Fix broken logo fallbacksrc, update examples list to match actual filesreference/Language.md: Document arrow functions,typeofsemantics, unary plus, comments, semicolon-free statements,console.log, named function expressionsreference/Math.md: Add edge case notes forMath.max()/Math.min()reference/Types.md: Fix grammarCONTRIBUTING.md: Clarify CI verification and improve wordingCHANGELOG.md,.github/PULL_REQUEST_TEMPLATE.md, issue templatesVerification
REFERENCE.mdregenerated