From 06aef5ffca85c888f652d6d58f3c12d1774f7706 Mon Sep 17 00:00:00 2001 From: siwuxie Date: Tue, 21 Jan 2025 23:04:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor(stat):=20=E4=BC=98=E5=8C=96=20LeapArra?= =?UTF-8?q?y=20=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E5=B9=B6=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=20util=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 leap_array.go 中,使用更简洁的方式计算 base地址 - 删除整个 util/safe.go 文件,该文件未被使用 Signed-off-by: siwuxie --- core/stat/base/leap_array.go | 4 +--- util/safe.go | 30 ------------------------------ 2 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 util/safe.go diff --git a/core/stat/base/leap_array.go b/core/stat/base/leap_array.go index 9d6a253b7..897380818 100644 --- a/core/stat/base/leap_array.go +++ b/core/stat/base/leap_array.go @@ -90,9 +90,7 @@ func NewAtomicBucketWrapArrayWithTime(len int, bucketLengthInMs uint32, now uint startTime += uint64(bucketLengthInMs) } - // calculate base address for real data array - sliHeader := (*util.SliceHeader)(unsafe.Pointer(&ret.data)) - ret.base = unsafe.Pointer((**BucketWrap)(unsafe.Pointer(sliHeader.Data))) + ret.base = unsafe.Pointer(&ret.data[0]) return ret } diff --git a/util/safe.go b/util/safe.go deleted file mode 100644 index 3eedc6db9..000000000 --- a/util/safe.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 1999-2020 Alibaba Group Holding Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package util - -import "unsafe" - -// SliceHeader is a safe version of SliceHeader used within this project. -type SliceHeader struct { - Data unsafe.Pointer - Len int - Cap int -} - -// StringHeader is a safe version of StringHeader used within this project. -type StringHeader struct { - Data unsafe.Pointer - Len int -}