Skip to content

Commit

Permalink
more optimziations for servo
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Oct 20, 2023
1 parent 81f4234 commit edd6274
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions servo/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ namespace modules {
this.start()
this.setEnabled(true)
const values = this._angle.values as any[]
values[0] = value
this._angle.values = values as [number]
if (value !== values[0]) {
values[0] = value
this._angle.values = values as [number]
}
}

private internalSetContinuous(enabled: boolean) {
Expand Down Expand Up @@ -179,8 +181,10 @@ namespace modules {
setEnabled(value: boolean) {
this.start()
const values = this._enabled.values as any[]
values[0] = value ? 1 : 0
this._enabled.values = values as [boolean]
if (!!value !== !!values[0]) {
values[0] = value ? 1 : 0
this._enabled.values = values as [boolean]
}
}

/**
Expand All @@ -203,8 +207,10 @@ namespace modules {
setOffset(value: number) {
this.start()
const values = this._offset.values as any[]
values[0] = value
this._offset.values = values as [number]
if (value !== values[0]) {
values[0] = value
this._offset.values = values as [number]
}
}

/**
Expand Down Expand Up @@ -242,8 +248,10 @@ namespace modules {
setMinPulse(value: number) {
this.start()
const values = this._minPulse.values as any[]
values[0] = value
this._minPulse.values = values as [number]
if (value !== values[0]) {
values[0] = value
this._minPulse.values = values as [number]
}
}

/**
Expand Down Expand Up @@ -281,8 +289,10 @@ namespace modules {
setMaxPulse(value: number) {
this.start()
const values = this._maxPulse.values as any[]
values[0] = value
this._maxPulse.values = values as [number]
if (value !== values[0]) {
values[0] = value
this._maxPulse.values = values as [number]
}
}

/**
Expand Down

0 comments on commit edd6274

Please sign in to comment.