Skip to content

Commit

Permalink
perf: Use MOZ_ASSERT instead of MOZ_RELEASE_ASSERT as these methods a…
Browse files Browse the repository at this point in the history
…re already guarded correctly where they are being called (fastly#876)
  • Loading branch information
JakeChampion authored Jul 31, 2024
1 parent 1820b0b commit f089616
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions runtime/fastly/builtins/cache-override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ void CacheOverride::set_mode(JSObject *self, CacheOverride::CacheOverrideMode mo

JS::Value CacheOverride::ttl(JSObject *self) {
MOZ_ASSERT(is_instance(self));
if (CacheOverride::mode(self) != CacheOverride::CacheOverrideMode::Override)
if (CacheOverride::mode(self) != CacheOverride::CacheOverrideMode::Override) {
return JS::UndefinedValue();
}
return JS::GetReservedSlot(self, Slots::TTL);
}

void CacheOverride::set_ttl(JSObject *self, uint32_t ttl) {
MOZ_ASSERT(is_instance(self));
MOZ_RELEASE_ASSERT(mode(self) == CacheOverride::CacheOverrideMode::Override);
MOZ_ASSERT(mode(self) == CacheOverride::CacheOverrideMode::Override);
JS::SetReservedSlot(self, CacheOverride::Slots::TTL, JS::Int32Value((int32_t)ttl));
}

Expand All @@ -48,7 +49,7 @@ JS::Value CacheOverride::swr(JSObject *self) {

void CacheOverride::set_swr(JSObject *self, uint32_t swr) {
MOZ_ASSERT(is_instance(self));
MOZ_RELEASE_ASSERT(CacheOverride::mode(self) == CacheOverride::CacheOverrideMode::Override);
MOZ_ASSERT(CacheOverride::mode(self) == CacheOverride::CacheOverrideMode::Override);
JS::SetReservedSlot(self, CacheOverride::Slots::SWR, JS::Int32Value((int32_t)swr));
}

Expand All @@ -61,7 +62,7 @@ JS::Value CacheOverride::surrogate_key(JSObject *self) {

void CacheOverride::set_surrogate_key(JSObject *self, JSString *key) {
MOZ_ASSERT(is_instance(self));
MOZ_RELEASE_ASSERT(CacheOverride::mode(self) == CacheOverride::CacheOverrideMode::Override);
MOZ_ASSERT(CacheOverride::mode(self) == CacheOverride::CacheOverrideMode::Override);
JS::SetReservedSlot(self, CacheOverride::Slots::SurrogateKey, JS::StringValue(key));
}

Expand All @@ -74,7 +75,7 @@ JS::Value CacheOverride::pci(JSObject *self) {

void CacheOverride::set_pci(JSObject *self, bool pci) {
MOZ_ASSERT(is_instance(self));
MOZ_RELEASE_ASSERT(CacheOverride::mode(self) == CacheOverride::CacheOverrideMode::Override);
MOZ_ASSERT(CacheOverride::mode(self) == CacheOverride::CacheOverrideMode::Override);
JS::SetReservedSlot(self, CacheOverride::Slots::PCI, JS::BooleanValue(pci));
}

Expand Down

0 comments on commit f089616

Please sign in to comment.