Skip to content

Commit

Permalink
cleanup: use simplify sortedProperties to potentially more JS allocat…
Browse files Browse the repository at this point in the history
…or friendly way
  • Loading branch information
G4Vi committed Nov 19, 2024
1 parent b46f6d8 commit e89d637
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,12 @@ function numRequiredProperties(object: Schema) {

function sortedProperties(object: Schema) {
const properties: Property[] = []
let curRequiredProperties = 0
const requiredProperties: Property[] = []
for (const prop of object.properties) {
if (!isPropertyRequired(prop)) {
properties.push(prop)
continue;
}
properties.splice(curRequiredProperties, 0, prop)
curRequiredProperties++
const target = (isPropertyRequired(prop) ? requiredProperties : properties)
target.push(prop)
}
return properties
return [...requiredProperties, ...properties]
}

function isTypeUntypedObject(type: XtpNormalizedType) {
Expand Down

0 comments on commit e89d637

Please sign in to comment.