# US 10,481,882 B2 · Reducing waste areas inside strings

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 10,481,882 B2
- Document ID: US10481882B2
- Status: Granted
- Kind: B2
- Application number: 15/288,499
- Filed: 2016-10-07
- Published: 2018-04-12
- Granted: 2019-11-19
- Earliest claimed: 2016-10-07
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Kiyokuni Kawachiya
- Web page: https://patentgrep.com/patent/US10481882B2

## CPC

- G06F 8/4434: {Reducing the memory space required by the program code}
- G06F 12/02: Addressing or allocation; Relocation (program address sequencing G06F9/00; arrangements for selecting an address in a digital store G11C8/00)
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A computer-implemented method is presented for removing overlap character array of a programming language where a part of the character array is used as a value of a string. The computer-implemented method includes, when comparison of a first string and a second string succeeds, modifying the string using a larger character array to use a smaller character array. The computer implemented method further includes collecting the larger character array in a subsequent GC process. When the offset of the string's value in the character array needs to be used, it is atomically accessed with the value field by using the two-word compare and swap instruction or by allocating the value and offset field in the same word.

## Claims

### Claim 1

A computer-implemented method executed on a processor for removing overlap character array of a programming language where a part of the character array is used as a value of a target string, the method comprising:
comparing a character array size of a first string with a character array size of a second string;
if the character array sizes are different, modifying the target string by replacing a larger character array with a smaller character array;
collecting the larger character array in a subsequent string garbage collection (GC) process; and
permitting a string object of the target string to be accessed by other threads in parallel such that value and offset fields are atomically accessed and declared private in the string GC process where the larger character array is collected, so that user programs are prevented from accessing the value and offset fields directly.

### Claim 2 (depends on 1)

The method of claim 1, wherein modification of the target string involves replacing an offset value of the target string.

### Claim 3 (depends on 2)

The method of claim 2, wherein the value and offset fields reference the character array in a same word of a string object.

### Claim 4 (depends on 3)

The method of claim 3, wherein the value and the offset fields are atomically accessed by normal read/write operations.

### Claim 5 (depends on 4)

The method of claim 4, wherein the atomic access is enabled by two-word compare and swap instructions.

### Claim 6 (depends on 1)

The method of claim 1, wherein a count field of the first and second strings is not modified by the replacing of the larger character array with the smaller character array.

### Claim 7

A computer system for removing overlap character array of a programming language where a part of the character array is used as a value of a target string, the computer system comprising:
a memory; and
a processor in communication with the memory, wherein the computer system is configured to:
compare a character array size of a first string with a character array size of a second string;
if the character array sizes are different, modify the target string by replacing a larger character array with a smaller character array;
collect the larger character array in a subsequent string garbage collection (GC) process; and
permit a string object of the target string to be accessed by other threads in parallel such that value and offset fields are atomically accessed and declared private in the string GC process where the larger character array is collected, so that user programs are prevented from accessing the value and offset fields directly.

### Claim 8 (depends on 7)

The computer system of claim 7, wherein modification of the target string involves replacing an offset value of the target string.

### Claim 9 (depends on 8)

The computer system of claim 8, wherein the value and offset fields reference the character array in a same word of a string object.

### Claim 10 (depends on 9)

The computer system of claim 9, wherein the value and the offset fields are atomically accessed by normal read/write operations.

### Claim 11 (depends on 10)

The computer system of claim 10, wherein the atomic access is enabled by two-word compare and swap instructions.

### Claim 12 (depends on 7)

The computer system of claim 7, wherein a count field of the first and second strings is not modified by the replacing of the larger character array with the smaller character array.

### Claim 13

A non-transitory computer readable storage medium comprising a computer readable program for removing overlap character array of a programming language where a part of the character array is used as a value of a target string, wherein the computer readable program when executed on a computer causes the computer to perform the steps of:
comparing a character array size of a first string with a character array size of a second string;
if the character array sizes are different, modifying the target string by replacing a larger character array with a smaller character array;
collecting the larger character array in a subsequent string garbage collection (GC) process; and
permitting a string object of the target string to be accessed by other threads in parallel such that value and offset fields are atomically accessed and declared private in the string GC process where the larger character array is collected, so that user programs are prevented from accessing the value and offset fields directly.

### Claim 14 (depends on 13)

The non-transitory computer readable storage medium of claim 13, wherein the first string having a first value field and the second string having a second value field, the larger value field defining a larger character array and the smaller value field defining a smaller character array.

### Claim 15 (depends on 13)

The non-transitory computer readable storage medium of claim 13, wherein the method allocates value and offset fields that reference the character array in a same word of a string object.

### Claim 16 (depends on 13)

The non-transitory computer readable storage medium of claim 13, wherein a count field of the first and second strings is not modified by the replacing of the larger character array with the smaller character array.
