Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use java.lang.System.arraycopy for memmove.
  • Loading branch information
timo committed Jul 25, 2013
1 parent fb241ae commit 24c14a7
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 56 deletions.
@@ -1,5 +1,7 @@
package org.perl6.nqp.sixmodel.reprs;

import java.lang.System;

import org.perl6.nqp.runtime.ExceptionHandling;
import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.SixModelObject;
Expand Down Expand Up @@ -240,14 +242,7 @@ else if (tail > 0 && count > elems1) {
}

private void memmove(SixModelObject[] slots, long dest_start, long src_start, long l_n) {
// There are more optimal ways to do this (without the double copying),
// this is just the easiest possible implementation.
int n = (int)l_n;
SixModelObject[] temp = new SixModelObject[n];
for (int i = 0; i < n; i++)
temp[i] = slots[(int)src_start + i];
for (int i = 0; i < n; i++)
slots[(int)dest_start + i] = temp[i];
System.arraycopy(slots, (int)src_start, slots, (int)dest_start, (int)l_n);
}

public SixModelObject clone(ThreadContext tc) {
Expand Down
@@ -1,5 +1,7 @@
package org.perl6.nqp.sixmodel.reprs;

import java.lang.System;

import org.perl6.nqp.runtime.ExceptionHandling;
import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.SixModelObject;
Expand Down Expand Up @@ -245,14 +247,7 @@ else if (tail > 0 && count > elems1) {
}

private void memmove(long[] slots, long dest_start, long src_start, long l_n) {
// There are more optimal ways to do this (without the double copying),
// this is just the easiest possible implementation.
int n = (int)l_n;
long[] temp = new long[n];
for (int i = 0; i < n; i++)
temp[i] = slots[(int)src_start + i];
for (int i = 0; i < n; i++)
temp[(int)dest_start + i] = temp[i];
System.arraycopy(slots, (int)src_start, slots, (int)dest_start, (int)l_n);
}

public SixModelObject clone(ThreadContext tc) {
Expand Down
@@ -1,5 +1,7 @@
package org.perl6.nqp.sixmodel.reprs;

import java.lang.System;

import org.perl6.nqp.runtime.ExceptionHandling;
import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.SixModelObject;
Expand Down Expand Up @@ -245,14 +247,7 @@ else if (tail > 0 && count > elems1) {
}

private void memmove(short[] slots, long dest_start, long src_start, long l_n) {
// There are more optimal ways to do this (without the double copying),
// this is just the easiest possible implementation.
int n = (int)l_n;
short[] temp = new short[n];
for (int i = 0; i < n; i++)
temp[i] = slots[(int)src_start + i];
for (int i = 0; i < n; i++)
temp[(int)dest_start + i] = temp[i];
System.arraycopy(slots, (int)src_start, slots, (int)dest_start, (int)l_n);
}

public SixModelObject clone(ThreadContext tc) {
Expand Down
@@ -1,5 +1,7 @@
package org.perl6.nqp.sixmodel.reprs;

import java.lang.System;

import org.perl6.nqp.runtime.ExceptionHandling;
import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.SixModelObject;
Expand Down Expand Up @@ -245,14 +247,7 @@ else if (tail > 0 && count > elems1) {
}

private void memmove(int[] slots, long dest_start, long src_start, long l_n) {
// There are more optimal ways to do this (without the double copying),
// this is just the easiest possible implementation.
int n = (int)l_n;
int[] temp = new int[n];
for (int i = 0; i < n; i++)
temp[i] = slots[(int)src_start + i];
for (int i = 0; i < n; i++)
temp[(int)dest_start + i] = temp[i];
System.arraycopy(slots, (int)src_start, slots, (int)dest_start, (int)l_n);
}

public SixModelObject clone(ThreadContext tc) {
Expand Down
@@ -1,5 +1,7 @@
package org.perl6.nqp.sixmodel.reprs;

import java.lang.System;

import org.perl6.nqp.runtime.ExceptionHandling;
import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.SixModelObject;
Expand Down Expand Up @@ -245,14 +247,7 @@ else if (tail > 0 && count > elems1) {
}

private void memmove(byte[] slots, long dest_start, long src_start, long l_n) {
// There are more optimal ways to do this (without the double copying),
// this is just the easiest possible implementation.
int n = (int)l_n;
byte[] temp = new byte[n];
for (int i = 0; i < n; i++)
temp[i] = slots[(int)src_start + i];
for (int i = 0; i < n; i++)
temp[(int)dest_start + i] = temp[i];
System.arraycopy(slots, (int)src_start, slots, (int)dest_start, (int)l_n);
}

public SixModelObject clone(ThreadContext tc) {
Expand Down
@@ -1,5 +1,7 @@
package org.perl6.nqp.sixmodel.reprs;

import java.lang.System;

import org.perl6.nqp.runtime.ExceptionHandling;
import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.SixModelObject;
Expand Down Expand Up @@ -245,14 +247,7 @@ else if (tail > 0 && count > elems1) {
}

private void memmove(double[] slots, long dest_start, long src_start, long l_n) {
// There are more optimal ways to do this (without the double copying),
// this is just the easiest possible implementation.
int n = (int)l_n;
double[] temp = new double[n];
for (int i = 0; i < n; i++)
temp[i] = slots[(int)src_start + i];
for (int i = 0; i < n; i++)
temp[(int)dest_start + i] = temp[i];
System.arraycopy(slots, (int)src_start, slots, (int)dest_start, (int)l_n);
}

public SixModelObject clone(ThreadContext tc) {
Expand Down
@@ -1,5 +1,7 @@
package org.perl6.nqp.sixmodel.reprs;

import java.lang.System;

import org.perl6.nqp.runtime.ExceptionHandling;
import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.SixModelObject;
Expand Down Expand Up @@ -245,14 +247,7 @@ else if (tail > 0 && count > elems1) {
}

private void memmove(String[] slots, long dest_start, long src_start, long l_n) {
// There are more optimal ways to do this (without the double copying),
// this is just the easiest possible implementation.
int n = (int)l_n;
String[] temp = new String[n];
for (int i = 0; i < n; i++)
temp[i] = slots[(int)src_start + i];
for (int i = 0; i < n; i++)
temp[(int)dest_start + i] = temp[i];
System.arraycopy(slots, (int)src_start, slots, (int)dest_start, (int)l_n);
}

public SixModelObject clone(ThreadContext tc) {
Expand Down

0 comments on commit 24c14a7

Please sign in to comment.