Re: why does the int_value of the pa_json_object structure need to be declared as int64_t?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 8 Jul 2024, at 3:41 AM, 赵成义 wrote:
> Hi guys,
>
> Please help explain why the int_value of the pa_json_object structure 
> needs to be declared as int64_t.

I picked an int64_t because JSON does not specify a number precision, and I wanted to get the largest representation we could without having to actually resort to arbitrary precision integers.

> ./src/pulsecore/json.c:
>
> struct pa_json_object {
>     pa_json_type type;
>
>     union {
>         int64_t int_value;
>         double double_value;
>         bool bool_value;
>         char *string_value;
>         pa_hashmap *object_values; /* name -> object */
>         pa_idxset *array_values; /* objects */
>     };
> };
>
> Can I change "int64_t int_value;" to "int int_value;"?
> In the ./src/pulse/format.c file, the function pa_json_object_get_int
> is called multiple times, converting int64_t to int.

Can you share a rationale for wanting to do this? On 64-bit systems, this conversion is a no-op, anyway, and on 32-bit systems I would expect the overhead to be minimal.

-- Arun




[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux