Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
1203-diameter-replace-size-1-by-xxx_size-1.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1203-diameter-replace-size-1-by-xxx_size-1.patch of Package erlang
From 9e2fe13160544f857410be5b946d8177247c25f5 Mon Sep 17 00:00:00 2001 From: Kiko Fernandez-Reyes <kiko@erlang.org> Date: Fri, 10 Feb 2023 08:05:57 +0100 Subject: [PATCH] diameter: replace size/1 by xxx_size/1 The <c>size/1</c> BIF is not optimized by the JIT, and its use can result in worse types for Dialyzer. When one knows that the value being tested must be a tuple, <c>tuple_size/1</c> should always be preferred. When one knows that the value being tested must be a binary, <c>byte_size/1</c> should be preferred. However, <c>byte_size/1</c> also accepts a bitstring (rounding up size to a whole number of bytes), so one must make sure that the call to <c>byte_size/</c> is preceded by a call to <c>is_binary/1</c> to ensure that bitstrings are rejected. Note that the compiler removes redundant calls to <c>is_binary/1</c>, so if one is not sure whether previous code had made sure that the argument is a binary, it does not harm to add an <c>is_binary/1</c> test immediately before the call to <c>byte_size/1</c>. --- lib/diameter/src/info/diameter_dbg.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/diameter/src/info/diameter_dbg.erl b/lib/diameter/src/info/diameter_dbg.erl index 98d2bec77b..e9a8ab6417 100644 --- a/lib/diameter/src/info/diameter_dbg.erl +++ b/lib/diameter/src/info/diameter_dbg.erl @@ -218,7 +218,7 @@ pp(<<_Version:8, MsgLength:24, _/binary>> = Bin) -> pp(Bin) when is_binary(Bin) -> - {truncated_binary, size(Bin)}; + {truncated_binary, byte_size(Bin)}; pp(_) -> not_binary. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor