<commit_before>import * as React from "react";
import { NumberCell } from "@dcos/ui-kit";

import Pod from "../structs/Pod";
import Service from "../structs/Service";
import ServiceTree from "../structs/ServiceTree";
import Units from "#SRC/js/utils/Units";
import { SortDirection } from "plugins/services/src/js/types/SortDirection";
import ServiceTableUtil from "../utils/ServiceTableUtil";

export function diskRenderer(
  service: Service | Pod | ServiceTree
): React.ReactNode {
  const resource = service.getResources()[`disk`];

  return (
    <NumberCell>
      <span>{Units.formatResource("disk", resource)}</span>
    </NumberCell>
  );
}

export function diskSorter(
  data: Array<Service | Pod | ServiceTree>,
  sortDirection: SortDirection
): any {
  return ServiceTableUtil.sortData(data, sortDirection, "disk");
}<commit_msg>perf(services): avoid rerenders for disk column<commit_after>import * as React from "react";
import { NumberCell } from "@dcos/ui-kit";

import Pod from "../structs/Pod";
import Service from "../structs/Service";
import ServiceTree from "../structs/ServiceTree";
import Units from "#SRC/js/utils/Units";
import { SortDirection } from "plugins/services/src/js/types/SortDirection";
import ServiceTableUtil from "../utils/ServiceTableUtil";

export const ServiceDisk = React.memo(({ resource }: { resource: string }) => (
  <NumberCell>
    <span>{Units.formatResource("disk", resource)}</span>
  </NumberCell>
));

export function diskRenderer(
  service: Service | Pod | ServiceTree
): React.ReactNode {
  return <ServiceDisk resource={service.getResources()[`disk`]} />;
}

export function diskSorter(
  data: Array<Service | Pod | ServiceTree>,
  sortDirection: SortDirection
): any {
  return ServiceTableUtil.sortData(data, sortDirection, "disk");
}
{'fraction_non_alphanumeric': 0.14500836586726157, 'fraction_numerical': 0.0, 'mean_word_length': 5.040404040404041, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3520231', 'n_tokens_mistral': 515, 'n_tokens_neox': 516, 'n_words': 137}