Use shared Temporal property names in PlainDate parsing#315
Conversation
- Replace string literals with PROP_YEAR, PROP_MONTH, and PROP_DAY - Format missing-property errors with the shared property names
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughReplaced hardcoded temporal property name literals with centralized constants and consolidated repeated type-error messages into a single formatted message in the CoercePlainDate implementation. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
units/Goccia.Values.TemporalPlainDate.pas (1)
131-137: Optional: compute the required-fields error message once.The same
Format(...)call is repeated three times; extracting it improves readability and avoids duplication.♻️ Proposed refactor
function CoercePlainDate(const AValue: TGocciaValue; const AMethod: string): TGocciaTemporalPlainDateValue; var DateRec: TTemporalDateRecord; TimeRec: TTemporalTimeRecord; Obj: TGocciaObjectValue; V, VMonth, VDay: TGocciaValue; + RequiredPropsError: string; begin @@ else if AValue is TGocciaObjectValue then begin Obj := TGocciaObjectValue(AValue); + RequiredPropsError := Format('%s requires %s, %s, %s properties', [AMethod, PROP_YEAR, PROP_MONTH, PROP_DAY]); V := Obj.GetProperty(PROP_YEAR); if (V = nil) or (V is TGocciaUndefinedLiteralValue) then - ThrowTypeError(Format('%s requires %s, %s, %s properties', [AMethod, PROP_YEAR, PROP_MONTH, PROP_DAY]), SSuggestTemporalFromArg); + ThrowTypeError(RequiredPropsError, SSuggestTemporalFromArg); VMonth := Obj.GetProperty(PROP_MONTH); if (VMonth = nil) or (VMonth is TGocciaUndefinedLiteralValue) then - ThrowTypeError(Format('%s requires %s, %s, %s properties', [AMethod, PROP_YEAR, PROP_MONTH, PROP_DAY]), SSuggestTemporalFromArg); + ThrowTypeError(RequiredPropsError, SSuggestTemporalFromArg); VDay := Obj.GetProperty(PROP_DAY); if (VDay = nil) or (VDay is TGocciaUndefinedLiteralValue) then - ThrowTypeError(Format('%s requires %s, %s, %s properties', [AMethod, PROP_YEAR, PROP_MONTH, PROP_DAY]), SSuggestTemporalFromArg); + ThrowTypeError(RequiredPropsError, SSuggestTemporalFromArg);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@units/Goccia.Values.TemporalPlainDate.pas` around lines 131 - 137, The repeated Format(...) string for the required-fields error should be computed once into a local variable (e.g., RequiredFieldsMsg) before the property checks and then reused in the three ThrowTypeError calls; update the code around ThrowTypeError/Format that references AMethod, PROP_YEAR, PROP_MONTH, PROP_DAY so each check (VYear, VMonth, VDay) calls ThrowTypeError(RequiredFieldsMsg, SSuggestTemporalFromArg) instead of repeating the Format expression.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@units/Goccia.Values.TemporalPlainDate.pas`:
- Around line 131-137: The repeated Format(...) string for the required-fields
error should be computed once into a local variable (e.g., RequiredFieldsMsg)
before the property checks and then reused in the three ThrowTypeError calls;
update the code around ThrowTypeError/Format that references AMethod, PROP_YEAR,
PROP_MONTH, PROP_DAY so each check (VYear, VMonth, VDay) calls
ThrowTypeError(RequiredFieldsMsg, SSuggestTemporalFromArg) instead of repeating
the Format expression.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d3da270d-9608-4c1f-824e-f15d6b937838
📒 Files selected for processing (1)
units/Goccia.Values.TemporalPlainDate.pas
Suite Timing
Measured on ubuntu-latest x64. |
Benchmark Results364 benchmarks Interpreted: 🟢 16 improved · 🔴 304 regressed · 44 unchanged · avg -6.9% arraybuffer.js — Interp: 🔴 12, 2 unch. · avg -7.2% · Bytecode: 🔴 3, 11 unch. · avg -1.2%
arrays.js — Interp: 🔴 18, 1 unch. · avg -8.0% · Bytecode: 🔴 7, 12 unch. · avg -1.7%
async-await.js — Interp: 🔴 6 · avg -6.2% · Bytecode: 🔴 4, 2 unch. · avg -2.1%
base64.js — Interp: 🔴 8, 2 unch. · avg -6.4% · Bytecode: 🟢 10 · avg +4.0%
classes.js — Interp: 🔴 19, 12 unch. · avg -4.9% · Bytecode: 🔴 8, 23 unch. · avg -2.1%
closures.js — Interp: 🔴 10, 1 unch. · avg -5.7% · Bytecode: 🟢 6, 5 unch. · avg +3.2%
collections.js — Interp: 🔴 12 · avg -12.2% · Bytecode: 🟢 1, 🔴 3, 8 unch. · avg -0.3%
destructuring.js — Interp: 🔴 21, 1 unch. · avg -8.0% · Bytecode: 🟢 2, 🔴 2, 18 unch. · avg -0.2%
fibonacci.js — Interp: 🔴 8 · avg -8.1% · Bytecode: 🔴 2, 6 unch. · avg -0.5%
float16array.js — Interp: 🟢 4, 🔴 25, 3 unch. · avg -3.1% · Bytecode: 🟢 7, 🔴 3, 22 unch. · avg +0.9%
for-of.js — Interp: 🔴 5, 2 unch. · avg -7.2% · Bytecode: 🟢 1, 6 unch. · avg +1.3%
helpers/bench-module.js — Interp: 0 · Bytecode: 0
iterators.js — Interp: 🔴 37, 5 unch. · avg -6.6% · Bytecode: 🟢 9, 🔴 7, 26 unch. · avg +0.2%
json.js — Interp: 🔴 20 · avg -8.7% · Bytecode: 🔴 3, 17 unch. · avg -1.6%
jsx.jsx — Interp: 🔴 21 · avg -7.0% · Bytecode: 🔴 11, 10 unch. · avg -3.4%
modules.js — Interp: 🔴 9 · avg -7.6% · Bytecode: 9 unch. · avg -0.7%
numbers.js — Interp: 🔴 11 · avg -11.8% · Bytecode: 🟢 2, 🔴 5, 4 unch. · avg -2.2%
objects.js — Interp: 🟢 4, 🔴 1, 2 unch. · avg +2.0% · Bytecode: 🔴 1, 6 unch. · avg -1.9%
promises.js — Interp: 🔴 12 · avg -8.4% · Bytecode: 🔴 2, 10 unch. · avg -0.5%
regexp.js — Interp: 🔴 5, 6 unch. · avg -2.2% · Bytecode: 🔴 2, 9 unch. · avg -1.4%
strings.js — Interp: 🔴 17, 2 unch. · avg -8.2% · Bytecode: 🔴 6, 13 unch. · avg -14.3%
typed-arrays.js — Interp: 🟢 5, 🔴 15, 2 unch. · avg -4.0% · Bytecode: 🟢 7, 🔴 9, 6 unch. · avg +0.6%
uint8array-encoding.js — Interp: 🟢 3, 🔴 12, 3 unch. · avg -13.7% · Bytecode: 🟢 2, 🔴 7, 9 unch. · avg +13.2%
Measured on ubuntu-latest x64. Benchmark ranges compare cached main-branch min/max ops/sec with the PR run; overlapping ranges are treated as unchanged noise. Percentage deltas are secondary context. |
- Build the Temporal.PlainDate object-property error once - Reuse it for missing year, month, and day checks
Summary
year,month, anddayproperty lookups with shared property name constants.Fixes #309